im a newbie to php ive built a small php upload script but i wont work every time it give me the following error :
Warning: move_uploaded_file(E:/server/xampp/htdocs) [function.move-uploaded-file]: failed to open stream: Permission denied in E:\server\xampp\htdocs\upload\index.php on line 3 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\DOCUME~1\ak007\LOCALS~1\Temp\php10.tmp' to 'E:/server/xampp/htdocs' in E:\server\xampp\htdocs\upload\index.php on line 3
Warning: move_uploaded_file(E:/server/xampp/htdocs) [function.move-uploaded-file]: failed to open stream: Permission denied in E:\server\xampp\htdocs\upload\index.php on line 3
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\DOCUME~1\ak007\LOCALS~1\Temp\php10.tmp' to 'E:/server/xampp/htdocs' in E:\server\xampp\htdocs\upload\index.php on line 3
and im on windows so there is no chmod thing and i downloaded another upload script and it works fine on my machine anyone can tell me what's wrong? heres the code :
<?php if (isset ($FILES[upload])){ $up = move_uploaded_file($FILES[upload][tmp_name] , "E:/server/xampp/htdocs/"); if($up){ echo "Uploaded!!!!"; } else{ echo "error!! Can't upload the file"; } } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <br> <br> <br> <br> <br> <table width="100%" border="0"> <tr> <td><form action="index.php" method="post" enctype="multipart/form-data" name="upload_form"> <p> <input name="upload" type="file" id="upload"> <br> <input type="submit" name="Submit" value="Submit"> </p> </form></td> </tr> </table> </body> </html>
<?php if (isset ($FILES[upload])){ $up = move_uploaded_file($FILES[upload][tmp_name] , "E:/server/xampp/htdocs/"); if($up){ echo "Uploaded!!!!"; } else{ echo "error!! Can't upload the file"; } } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head>
<body> <br> <br> <br> <br> <br> <table width="100%" border="0"> <tr> <td><form action="index.php" method="post" enctype="multipart/form-data" name="upload_form"> <p> <input name="upload" type="file" id="upload"> <br> <input type="submit" name="Submit" value="Submit"> </p> </form></td> </tr> </table> </body> </html>
Have you tried encoding your path with backslashes, as you're on Windows?
Also, it appears you are on an NT-type windows system, so the assertion that "there is no chmod thing" is not exactly true. If your hard disk uses NTFS instead of FAT/FAT32, then there is a basic, somewhat perverted concept of permissions. 😉
yeah i know that but why do other scripts i dll work on the same server also tried double back slashes
and on the linux server ive chmod the upload dir to 777 and placed the script in my root dir i get a diffrent error
Warning: move_uploaded_file(/home/???/public_html/upload/): failed to open stream: Is a directory in /home/???/public_html/up.php on line 3 Warning: move_uploaded_file(): Unable to move '/tmp/phpNx79gB' to '/home/???/public_html/upload/' in /home/???/public_html/up.php on line 3 error!! Can't upload the file
Warning: move_uploaded_file(/home/???/public_html/upload/): failed to open stream: Is a directory in /home/???/public_html/up.php on line 3
Warning: move_uploaded_file(): Unable to move '/tmp/phpNx79gB' to '/home/???/public_html/upload/' in /home/???/public_html/up.php on line 3 error!! Can't upload the file
Ahh. You need to provide not only the path, but also the filename for the "new" file. 🙂
oh such a fool i am btw thx!!!