upload script giving copy error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

upload script giving copy error

Post by Trip1 »

http://www.nomorepasting.com/paste.php?pasteID=9172
-----------------------------------------------------------------
Hello, Im writing an upload script for 6 pictures, and im getting this error when i try to copy something:

Warning</b>: copy(home/ecliptic/public_html/myface/mkelly09/img_tuto9-01a.jpg): failed to open stream: No such file or directory in <b>/home/ecliptic/public_html/myface/addpicture.php</b> on line <b>147</b><br />

I have no idea why its giving me this error, /home/ecliptic/public_html/mkelly09 exists and is chmodded 777.

Since theres alot of code in that link i gave you, focus in more on lines 145-220 since thats where i use the copy commands.

You will notice that for pic_6 I tried to change it so that it copies to /home/ecliptic/public_html/mkelly09 instead of the others which copy it to /home/ecliptic/public_html/mkelly09/file_name_here

It doesn't work in each case..

any help is appreciated, thanks in advance!
User avatar
rprins
Forum Commoner
Posts: 31
Joined: Sat Jun 21, 2003 5:46 pm

Post by rprins »

Just a quick question.

The directory is 0777, but are the files in the directory 0777? I have had this problem in the past and it would be something to look into.
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

RE

Post by Trip1 »

Yes the files and directory is chmodded 777, I have checked all the permissions twice now and they all are 777.
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

add / before home - leaving it off will (unless you force base directory) use a relative path.

btw - you should think about iterating a loop for multiple uploads rather than writing the code for every single one

<input type="file" name="upload_file[]" />
<input type="file" name="upload_file[]" />

foreach($_FILES['upload_file']['error'] AS $indx=>$value)
{
if($value == 0)
{
echo $_FILES['upload_file']['tmp_name'][$indx];
}
}
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

I also presume you have the first parameter in the copy statement

copy(from here, to here);
Post Reply