Page 1 of 1

copy() or move_uploaded_file

Posted: Thu Apr 22, 2010 12:37 pm
by eliddell
hi all,
i am creating a php script that will allow my user to upload an image from there computer to a folder on my website..
problem is that i am using godaddy shared hosting and the temp folder they use for php uploads is outside my sites root and thus gives me permission problems when i try to copy or move the temp file to a given directory..

the line of code that spits out the error is - $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); // Move Image From Temporary Location To Permanent Location

i get a permissions problem as stated and godaddy said that i can not change the permissions on the said temp folder that i am copying from.. they did say that perhaps i can use a different command.. i tried move_uploaded_file but still get the same error.. does anyone have ANY advise..

erik

Re: copy() or move_uploaded_file

Posted: Thu Apr 22, 2010 12:59 pm
by Christopher
eliddell wrote:i get a permissions problem as stated and godaddy said that i can not change the permissions on the said temp folder that i am copying from.. they did say that perhaps i can use a different command.. i tried move_uploaded_file but still get the same error.. does anyone have ANY advise.
First, you don't need to change permissions on the tmp folder, you need to change permissions on to directory to which you are copying the files. Second, you should use move_uploaded_file() for uploads.

Re: copy() or move_uploaded_file

Posted: Thu Apr 22, 2010 1:12 pm
by eliddell
trust me when i say, that the permissions on the folder i am moving it TO is set to 777 i tried using move_uploaded_file and still get an error..

that error
Warning: move_uploaded_file(/vegancookie.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\5343850\html\admin\editGal.php on line 97

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\phpF850.tmp' to '/vegancookie.jpg' in D:\Hosting\5343850\html\admin\editGal.php on line 97
ERROR: Unable to upload image.

Re: copy() or move_uploaded_file

Posted: Thu Apr 22, 2010 3:36 pm
by John Cartwright
Unable to move 'D:\Temp\php\phpF850.tmp' to '/vegancookie.jpg'
Hint: Take a look at the file path you are trying to move the to.

Re: copy() or move_uploaded_file

Posted: Thu Apr 22, 2010 6:06 pm
by Christopher
:roll: