Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Error Deleting Uploaded Files


I have a configuration script which creates a directory on the server, directory used for uploading files. Everything works fine (creation of the directory, uploading) but when I try to delete an uploaded file from this directory using total commander as ftp client I get the following error: "550 Delete operation failed".

The used code is something like this:

$cursuri = "../cursuri";
@mkdir($cursuri, 0777);

Note: if I use total commander "chmod 777 cursuri" I don't get any problems.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Deleting Uploaded File
I am using a from in which users enter data as well as upload a file. I also give them an opportunity to delete their entry. Currently I am deleting the entry from the database.

Name Uploaded Files
Does anyone know how to change the name of a file as it is uploaded? I think it has something to do with this line: Code: $HTTP_POST_FILES['uploadedFile']['name']; But if I touch the 'name' tag I just get errors.

Upload File Error 3: "The Uploaded File Was Only Partially Uploaded"
I've a file that starts like this:

<form id="pdsForm" method="post" action="/mcControlPanel.php"
class="mcForm" charset="UTF-8" enctype="multipart/form-data" >

and it contains this input:

<input id="biopic" name="biopic" type="file" />

The script recieving it does this:

$biopic = $this->core->getVar("biopic");
if (is_array($biopic)) {
print_r($biopic);

I get:

Array ( [name] =L-monkeySmall.jpg [type] =[tmp_name] =[error] =>
3 [size] =0 )

Error 3 is "Array ( [name] =L-monkeySmall.jpg [type] =[tmp_name]
=[error] =3 [size] =0 )". As you can see, 0 kilobytes were
uploaded.

What should I look for? I've been looking on the web for awhile and so
far I've found little useful information about what Error 3 typically
indicates.

Displaying Uploaded Files
I currently have a page that allows me to upload files from a User and store them in a dtabase. Once the submit button is pressed, the PHP page appears, and lists the results of the Upload (i.e. Size, Name, Type).

What I am wondering is if there is a way that when I press the submit button ,the actual file that was uploaded will be displayed in the PHP page in addition to the other results so that all can be seen at once? (i.e. a Mind Manager file - .mpp)

Renaming Uploaded Files
I'm trying right now to code a "user picture gallery" function into my website. I'm going to have it where when a user creates an account, a directory is created with thier account name as the directory name. This is where all their uploaded pictures will be.

Now, when a user uploades a picture (along with a caption, and the time and date it was uploaded, etc etc), my script will first enter in all this information into a MySQL table.

My question is this: how can I make PHP take the picture that was uploaded and rename it to something like "xxxx.jpg", where xxxx = an automatically incrementing number? The reason I need to do this is in case the user uploads two different pictures that have the same file names (this is going to be quite common, especially now in the age of digital pictures, when everytime you upload pictures from your camera to your computer, it names them the same file names -- like DSC80001.jpg blah blah you get the picture)

How Are Uploaded Files Stored ?
how are uploaded files stored ?...pls show me an example...

How To Rename Uploaded Files Via ID
i have a form that is used as a resume/ picture/ new application uploader
currently the files (resume and picturefile) is being uploaded and renamed via
the applicants firstname-lastname

now my problem is i dont know how to rename the files using ID since the the process
is the files or application must be uploaded first before an ID for that is created
thats why in my current code i used firstname and lastname to rename it
but my problem is if the applicants got the same names so i was thinking of
renaming the files via ID and not firstname-lastname Code:

How To Delete Files Uploaded And Now Owned By PHP
Within homes/ PHP creates a directory, it's an integer such as homes/999 or homes/345. Within that new directory, PHP uploads some graphics, .gif or .jpg.

The problem is, that directory and all those graphics are now "owned" by PHP, usually running as nobody or www. I can't delete them or copy them.

I've tried running a chown() within PHP to make myself the owner, but I get "operation not allowed".

The only solution I've found so far is to set umask(0), so that the directory and graphics have 777 permissions. I don't think that's very safe, though, is it?

Does anyone have any suggestions. I want to be able to delete or copy the files like they are mine, but only me or my group. I'm not running the server myself, but those who are seem willing to work with me.

Problem With Moving Uploaded Files
I am having a little trouble uploading files (html form with post) with
php...

I am trying to copy the file from its temporary upload directory to the
destination directory, however, the server threw this msg at me... what does
it mean? and how do I circumvent it?

$user_file_tmp_name = /tmp/phpTeA9Hs
$dest_name = /home/free3/user_product_images/jamesjiao/Alizee18.jpg

Warning: copy(): open_basedir restriction in effect. File(/tmp/phpTeA9Hs) is
not within the allowed path(s): (/home/free3) in
/home/free3/my-page-admin.php on line 91

I tried both the copy() function and the move_uploaded_file() function and
got the same warning.

Problem With Renaming Files Before Beeing Uploaded.
I'm making a script that renames files (pictures) uploaded by users. All the filenames have to be unique, so if the filename already exists I have to rename it. How do I do that? I tried to use the rename()-function, but that didn't work because both the files in question have be located on the server for rename() to work. That doesn't work for me because all the files is uploaded in the same directory, and you can't have two files with the same name in the same directory without one of them getting overwritten.

So what I need is a script that checks if the file that gets uploaded already exists on the server. if it does, it have to be renamed to someting unique ->before<- it gets uploaded. The names of the already uploded files is stored in a database.

I've made this script, but it doesn't work and I don't know how to make it. The php-script and the uploaded files are in different directories. Anyone have a solution to this problem??

<?

//Connecting to DB
mysql_connect("my hostname","myuser","mypasword");
mysql_select_db("mydb");

//Querying DB
$query = "SELECT picture FROM Ad"; //picture holds the name of the pictures already uploaded
$result = mysql_query($query) or die(mysql_error());

//Checking if the picture alreadey exists in the database
while($i = mysql_fetch_row($result))
{
if($picture_name == $i[0]) //$picture_name is the name of picture the user has uploaded through a form
{

//Removing whitespaces before or after the picture_name
$picture_name = trim($picture_name);

//removing whitespaces in the middle of the picture name
$picture_name = str_replace(" ", "", $picture_name);

//extracting fileextension from the last post in $filext_array
$fileext_array = explode(".",$picture_name);
$fileexst = $fileext_array[count($fileext_array)-1];

//Making the new unique filename using current UNIX timestamp
$unix_time = time();
$new_name = $unix_time.".".$fileexst;

//Renaming filename. Get error on this line: "Warning: Rename failed (No such file or directory)"
rename($picture_name,$new_name); //is it because the picture is not yeat uploaded to the server??
}
}

//Uploading picture to server
$the_path= "/home/kvien/www/club-honda/pictures";

copy($bilde,$the_path . "/" . $bilde_name) or die("Can't copy picture.");

$query = "insert into Ad values ('$name','$membernumber','$picture_name')";
$result = mysql_query($query) or die(mysql_error());
?>

Is_file() Returns False For Uploaded Files?
Running IIS 6 on Windows 2003 server.

After an update to the most recent version of php 5.1.2, for some reacon
a function handling uploaded files using is_file stopped working. is_file
failed for existing files. I fixed it by changing is_file to
file_exists, then it worked again. Prior to the update, in the older
version, presumably it was 5.0.1, is_file worked just fine without
problems.

<?php
echo 'is_file:' . (is_file($_FILES['myfile']['tmp_name']) ? 'true' :
'false');
echo 'file_exists:' . (file_exists($_FILES['myfile']['tmp_name']) ? 'true' :
'false');
?>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>"
enctype="multipart/form-data" method="post">
<input type="file" name="myfile" />
<input type="submit" />
</form>

Submitted a bug report already http://bugs.php.net/bug.php?id=37118

Change File Permissions On Uploaded Files?
I am trying to find a way to change the default file permissions for uploaded files using PHP. When I upload a file using my PHP script the default file permissions are 755. I would like the file to have 744.

Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?

Deleting Files
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:

Deleting Files
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?

Deleting Files
I'm trying to modify this script to remove files that end with %enlarged.jpg or %enlarged.gif or %enlarged.png, can someone help with the if statement, I've tried several things, of which, nothing is working: Code:

Deleting Files
I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Code:

Uploaded File Is Not Returning An Error
I've set up a file upload script for my users. When a user uploads a file that is larger than the max_post_size, the script runs for an unusually long time and fails to set any errors in the $_FILE array. An upload that is larger than max_file_size and less than max_post_size will generate errors as expected. It appears that the script fails to finish reading the post data and continues to churn along. If anyone has experienced this issue before, I would greatly appreciate some advice.

For what it is worth:
IIS 5 Win2k Server
PHP 4.3.9

Error Deleting Row (error 1064)
I am running this sql statement:

$query = "DELETE FROM customer
WHERE cust_id = " .$custID;

I get "error 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2"
This doesn't make sense to me, since in the same script I have:

$query = "SELECT * FROM customer
WHERE cust_id = " . $custID;

and it works just fine? I tried hardcoding the custID and the delete query worked just fine, how can I get it to work with my variable?

Deleting All Files With A Certain Prefix
I'm using php 4.4.4. Given a particular directory, I want to delete
all the files that begin with the variable "$prefix". What is the
simplest way to do this?

Deleting Files From A Folder...
I have a folder with many pictures in it.
All have the name like: HHMMDDMMYYYY.jpg

H-hour
M-minute
D-day
M-month
Y-year

Now I want to delete all pictures which are older than now()-7days.
How Can I do it? In SQL would be no prob but with file deleting is problem.

Deleting All The Files In A Directory
Using PHP 4, what are the shortest amount of lines I can write to
delete all the files in a given directory?

Deleting Files From A Server
As part of a project I want to allow users to save files to a server or delete files from a server. I have the uploader working fine, but i have no idea how i would delete the file from the server.

Attaching/deleting Files
I'm trying to create a tree where you can access files from the tree. The files will NOT be stored in the database, but on the server. I have a web forum eg, where they store the title of the message in a separate table compared with the message which is another table.

How do I store the files and show them on the tree, and how will the system know where to get the files from, if they're not in the database?

Deleting Files Onclick
I have an app that lists out the files on a server.  I have a checkbox at the end of each file.  You can check any number of files.  Then I have a link at the top that says "delete selected files."  Could someone just tell me how to write the code to delete the files in general?  I'm not asking for all the exact code, just the concept.  I assume I will be calling a php or javascript function with the "onclick" method. Code:

Fileupload - Error When 5mb Is Uploaded, Limit Is 50mb
I'm keep getting an "Invalid file" error and I can't fathom out in the slightest why its doing that! The file limit is supposed to be 50mb, and allowing zips and rars only. It works perfectly well when I upload like 2mb files, but the other night I attempted to upload a 5mb zip and it returned "invalid file". Its very odd because it uploaded the 3mb zip file fine, no errors. But at 5mb it just won't do it. I tried it at my friends house and it didn't work either. Could it be because my internet is to slow and its timing out or something? Anyway here is the script ....

Creating And Deleting Folders And Files
Hi to Everyone.

After creating trought http a organize number of files and folders. I'm not able to delete them, not even trought an FTP Software like Cute FTP. It replies "Could not delete xxxxx.html".

Deleting Files In A Folder Modified Before Certain Date
I use a cache system that requires creation of files in a folder .

Now , what i need to know is how can i delete files created say 3 days ago.

So that the cache remains fresh.

The directory contains around 20,000 files , about 10,000 are generated each day (if they dont exist)

So getting info about the each file after using opendir will cause the server to slow down.

Zend Studio 3.5.2 Possibly Deleting Files?
At work I'm using Zend Studio 3.5.2 to develop PHP files on my Win2K
desktop machine. I've got Zend Studio setup with a secure FTP (SFTP)
connection to a RedHat Enterprise Linux machine. The files I'm editing
'live' on a Solaris machine and the linux machine mounts them through
NFS. I actually access the files through a symbolic link to the mount
point on the linux box. A little complicated I know, but it does work.

I've been having a random problem lately. Every once in awhile (every
couple of weeks) when I'm in Zend Studio and have a few (not all) php
files open, all the files in the directory where I'm working get
corrupted. They all get turned to a file of nothing but nulls (zeros)
and the files are exactly 512 bytes long. This concerns me because it
seems to only happen to me even though other people work on PHP files
in other directories. The difference is that I'm the only one who uses
Zend Studio regularly. I can't see how that would be a problem since
the connection to the files is through SFTP and is essentially
stateless and connectionless. Has anyone else seen this problem or have
any insight about what might be going on?

Editing And Deleting Flat Text Files
I am working on a php news script that uses text files for it's DB. I have most of it done except for the ability to edit or delete the articles in the DB.

I have only been coding for about a week now so my skills are pretty limited and I have not found any tutorials that cover this issue so if anyone could be kind enough as to show me how this is done I would be most greatful....

Deleting Files Using Unlink [function.unlink]: Permission Denied
I have a record in the db and a picture file name recorded with that record. I am writing a deletion routine which checks that file name and is supposed to delete it using unlink.

Although it reports the correct directory and file name, I received the following:

Warning: unlink(/home/pab/html/pics/test.jpg) [function.unlink]: Permission denied

I checked my permissions and the file is set at my user name and 666.

Does anyone know why this won't work or maybe another way to delete the file?

Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error:

550 th: Permission denied
I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means.

I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine.

The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things.

I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of.

I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.

Deleting From Database, "SQL Sytax Error"
I searched the forums and I couldn't come up with anything, so I'm sorry if this has been solved before. But my problem is that when I want to delete a comment from the database, it just says, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1". At line one I have a Session_start...and I doubt that would interfere with deleting.

Here's my query:
$com = $_GET['del'];
if ($com != NULL && is_numeric($com)) {
  if ($ip == $okip) {
mysql_query("DELETE FROM `comments` WHERE `id` = '".$com."' LIMIT 1 ");
echo "Comment has been deleted.<META HTTP-EQUIV="REFRESH" CONTENT="2; URL=show.php"> ";
}
else {
echo "You do not have permission to delete comments."; }
}

No Error In Included Files
The problem is pretty simple.
If I include a file
<?
include 'libs.php'
?>

and this file contains an error (a missing ;),
my php installation does not tell me anything.
I simply receive no output.

Error While Writting Files
I need to write files on my local server .. Everything works fine... The problem is when writing new multiple files PHP freezes.  It just stop executing and freez. I assume the problem is while file is still being written and another command come to write new file ...

I tried to check with the function file_exists(), but the problem is that file exists, but it is now jet written...

I thought if there is any command to wait for let's say 4 seconds and than continue... But I didn't find anything.

Error While Copying Files After Upload
I'm trying to allow users to upload to the server. The system seems to upload okay (at least it takes a while for the page to refresh after the submit button is pressed). When the submit button is pressed and the files are uploaded, it reloads the script (a $PHP_SELF in the form tag).

What happens next is that it tries to copy the uploaded files (a maximum of 3 files can be uploaded) to a more permanent directory on the server. code:

500 Server Error Loading Php Files W/iis
I'm sure this question has been asked many times, but I couldn't find a thread that related to my setup, so I have to ask. I have a Windows XP pro machine setup w/IIS 5.1. I've got html, perl, and asp pages setup and working fine. But for some reason, I keep getting a file not found/500 server error when I try to load a simple php file.

I tested the file in the command prompt and it outputted the results as expected, so I know it's not a php problem. I'm using the dll file that I copied into the windows/system folder to load the scripts and setup a application configuration and filter setting, and stopped/started IIS. Same error.

Interpreting Error Messages From Include Files...
lets say i have the following files:

1. error.php: that is routed to for all errors. this page should
display proper and explanatory error messages to the user based on the
parameter provided.
2. errordef.php: has all the error codes and their explanations
"defined" as constants.

now, say if i have 3 different files viz. a.php, b.php and c.php, and
when any error occuring in either these files, i want to route to
error.php for detailed explanation. each a.php, b.php and c.php passes
error code to error.php, but error.php should interpret the code from
the definition file errordef.php!

Fopen Gives Error When Reading Files From The Same Domain
I have a script that is using fopen to see if a file exists or not. It works unless the file it is opening is on the same domain as it, then it gives these errors:

Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/narutof2/public_html/download.php on line 77

Warning: fopen(http://pubserver.narutofob.com/010.zip) [function.fopen]: failed to open stream: Permission denied in /home/narutof2/public_html/download.php on line 77

It looks like maybe fopen doesn't have the permissions to access the file, but I'm not sure what to do about it. Does anyone have any ideas what would cause this?

Uploading Large Files - Error "stat Failed"
I have a page where i can upload binary file (using the HTML input
type=file approach). This works fine for relatively small files
(<6MB)) but when files get bigger (13MB) there is a problem.
The code of the php file is based upon the article in
http://www.onlamp.com/pub/a/php/200...php_mysql.html: uploading
large binary files using more than one table and more trhan 1 row per
file.

When I want to upload something of -say- 13MB the problems are:

1 takes ages to upload (slow connection? it's on my LAN),

2 after a while I get a error msg:
"Warning: stat failed for none (errno=2 - No such file or directory)
in /Users/marc/Sites/wwwweb/FTP/FileTransfer.php on line 91"

Lines 90 and 91 are below:
90clearstatcache();
91$time = filemtime($SrcPathFile);

(does this mean the tmp file is not there???)

I changed 4 variables in php.ini to accomodate the bigger file size:

max_execution_time=120
post_max_size=65M
upload_max_filesize=65M
memory_limit =65M

I changed the rights on the tmp file upload directory so that everyone
can write to it just to be sure...

Still I get the error.

Why am I not able to upload those big files?

Why does it take so long for the file to upload to the server? It
happens all on my LAN (no proxies enabled) so it should be faster....
even dloading a file from the internet is faster than this.

Getting Name Of File Being Uploaded
i upload a thumbnail and larger picture using a form. i save that in a directory which is chmod 777. i then went to send both of the file names to a database, so the page which display the the thumbnail pictures, pulls the names out of a database and the correlating larger pic for it.

i have the steps correct to get it working but cannot find (due to lack of knowledge) how to figure out how to save the file name. doing it this way so the user does not have to alter file names, they take the pic and upload it. they are done.

Progress Uploaded?
I have an upload page and was wondering if there was a way to add some sort of X percent uploaded? Like some kind of progress indicator? These are such big files that it seems like the computer is freezing up.

Uploaded File Name
Here's what I want:
After uploading the file, I would like to preview the filename and the
original path uploaded from the client side and not what is now
uploaded to the server..

for example, C:mydocumentsmyfilesmyfile.doc
How can I do this?

Uploaded File Ok But Not Created
I'm trying to perform a very simple file upload page and everything seems to go just fine. The $_FILES var is populated with valid data (file size, name, mime type, even from a win remote computer) but the file just doesn't exists... It points to /tmp/php[random garbage] but there's no file starting with 'php'. /tmp is world-writeable so I don't see what the problem is. PHP Code:

Can't Replace Uploaded File
I have the following problem, I have a database (MySQL) in which I can store filenames, in my script I can select a file from my hard drive that will be uploaded and stored in a directory on the server. So far so good.

Now when I want to replace the file by another one and use the same script it won't replace the file. Does anybody outthere know what the problem might be??

The following code is my part of the script that does the uploading:

if ($img1_name != "") {

copy("$img1", "/home/sitename/www/dbasepictures/$img1_name") or die ("Couldn't copy the file!");

} else {

die("No input file specified");
}

Resizing An Uploaded Image
I finally figured out how to upload an image through an HTML form using PHP. I have the image in a directory. Now, the hard part - how do I take that imae ($photo) and resize it and save it as two different images - a thumbnail that is 75x50 and a full image that is 150x100.

Downloading An Uploaded .doc File
I am working on a site in which some members may browse/upload a Word document and other members may wish to download these and view them. I have tried saving the uploaded file like..

if (!copy($cv, "cvs/cv".$cid.".doc") ) {
echo("Problems encountered receiving your CV. However your application will still be processed.");}

and the download link like...

<A HREF='<?="/cvs/cv$cid.doc"?>'><B>View</B></A>

..and the browser opens Word and the file gets displayed. This is taking FAR to long to happen. What would be ideal is to simply click on the link and get the normal download dialog up. I also tried..

if (!copy($cv, "cvs/cv".$cid) ) {
...} and to view..

<A HREF='<?="/cvs/cv$cid"?>'><B>View</B></A>

..but I got a download dialog asking if I wanted to download CVxxx.txt but I need CVxxx.doc. Any ideas? I want to be prompted to download a Word Doc.

Mimetype Of An Uploaded File?
can anyone please help me on the mimetype of an uploaded file?

if i upload a jpg using IE, the mimetype showed by
$_FILES['filename']['type'] is "image/pjpeg" but if I use the same
script in Firefox, the mimetype shows "image/jpeg". Same with
uploading png files, in IE the mimetype shows "image/x-png", in
Firefox, it shows "image/png".

Can anyone please tell me why this difference occurs and how to get
rid of this? I am concerned because below is my code, this code works
fine in firefox but not in IE because of the changed mimetype.

$mimetype = $_FILES['imagefile']['type'];
$temporary_name = $_FILES['imagefile']['tmp_name'];
switch($mimetype) {
case "image/jpg":
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/jpeg":
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/gif":
$i = imagecreatefromgif($temporary_name);
break;
case "image/png":
$i = imagecreatefrompng($temporary_name);
break;
}

When I echo the $mimetype, i can see the different mimetypes in
different browser.

Resizing Uploaded Images
I want to have an option on my site to upload images. I then want to have PHP (or something) make a thumbnail version of the image automatically. Is this possible and how?


Copyright © 2005-08 www.BigResource.com, All rights reserved