Page 1 of 1

Upload problem

Posted: Tue Nov 22, 2005 1:12 pm
by ehsun7b
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I have a problem. I want to write a very simple upload script, I want to let the user to choose a file and clock submit and then my script should copy the selected file to one of the host's directories. I use this statement:

Code: Select all

if (copy($HTTP_POST_FILES['picfile']['tmp_name'], $_FILES['picfile']['name']))
                echo 'File successfuly copied!';
            else
                echo 'Not copied!';
It works on my local host, but on the server it leads in:
Warning: copy(AutoFix_2005-11-20_23-38-31.txt): failed to open stream: Permission denied in d:\accounts\tn-co\cpanel\addmember.php on line 94

What is the problem?


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Nov 22, 2005 2:09 pm
by Burrito
does the web user have permission to write to the folder in question?

Posted: Tue Nov 22, 2005 2:18 pm
by John Cartwright
you are using both $HTTP_POST_FILES and $_FILES.. which is bad. $HTTP_POST_FILES is deprecated, and is recommended to use $_FILES instead. Although if your looking to support older servers of php I would use $HTTP_POST_FILES.