Upload problem

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
User avatar
ehsun7b
Forum Newbie
Posts: 8
Joined: Tue Nov 22, 2005 12:33 am
Contact:

Upload problem

Post 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]
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

does the web user have permission to write to the folder in question?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Post Reply