Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File upload problems.

Status
Not open for further replies.

PhoenixDown

Programmer
Jul 2, 2001
279
0
0
CA
I'm still new at this and I can't get it to work. I'm using PHP 4.2:

Warning: Unable to open '' for reading: Permission denied in c:\appserv\ on line 907
Couldn't copy the file!

echo &quot;<form enctype=\&quot;multipart/form-data\&quot; name=\&quot;theform\&quot; action=\&quot;index.php\&quot; method=\&quot;post\&quot;>&quot;;
echo &quot;<input type=\&quot;hidden\&quot; name=\&quot;MAX_FILE_SIZE\&quot; value=\&quot;15728640\&quot;>&quot;;
echo &quot;<input type=\&quot;file\&quot; name=\&quot;backup\&quot; size=\&quot;30\&quot; maxlength=\&quot;150\&quot;>&quot;;

copy($_FILES['backup']['tmp_name'], &quot;C:\\AppServ\\www\\admin\\backups&quot;.$_FILES['backup']['name']) or die(&quot;Couldn't copy the file!&quot;);

Please help me out. Thanks.
 
Change
copy($_FILES['backup']['tmp_name'], &quot;C:\\AppServ\\www\\admin\\backups&quot;.$_FILES['backup']['name']) or die(&quot;Couldn't copy the file!&quot;);
to
if (!empty($_FILES['backup']['tmp_name']))
copy($_FILES['backup']['tmp_name'], &quot;C:\\AppServ\\www\\admin\\backups&quot;.$_FILES['backup']['name']) or die(&quot;Couldn't copy the file!&quot;);
This way it will only copy the file if a file was submitted, and if the tmp_name is set. //Daniel
 
You can't read the file from the local user's disk &quot;c:\AppServer\...&quot;, it(him) can read this file and press Submit, but can read the file on the server without problems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top