|
|
|
|
![]() ![]() |
Sep 19 2005, 10:07 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
i have never tried to have files uploaded and i am still not able to do so. here is the codes that i am using right out of the php manual and it still isnt working. i have also listed the warnings/errors listed on the resulting page. my permissions are set to 777 also. i have a folder set up on my server as "uploads". i am however not sure if i have a default temp folder on my server. can anyone help me figure out what i am not doing correctly or what my next step is?
this is the form that i am using: html Code: CODE <form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="userfile" type="file" /> <input type="submit" value="Upload File" /> </form> this is the php page "upload.php" php Code: CODE # # <?php # $uploadDir = '/uploads/'; # $uploadFile = $uploadDir . $_FILES['userfile']['name']; # print "<pre>"; # if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)) # { # print "File is valid, and was successfully uploaded. "; # print "Here's some more debugging info:\n"; # print_r($_FILES); # } # else # { # print "Possible file upload attack! Here's some debugging info:\n"; # print_r($_FILES); # } # print "</pre>"; # this is the resulting error: Code: CODE Warning: move_uploaded_file(/uploads/golf.jpg): failed to open stream: No such file or directory in /home/jesokcc/public_html/upload.php on line 5 Warning: move_uploaded_file(): Unable to move '/tmp/php72OLgu' to '/uploads/golf.jpg' in /home/jesokcc/public_html/upload.php on line 5 Possible file upload attack! Here's some debugging info: Array ( [userfile] => Array ( [name] => golf.jpg [type] => image/pjpeg [tmp_name] => /tmp/php72OLgu [error] => 0 [size] => 9802 ) ) Thanks,kvarnerexpress |
|
|
|
Sep 20 2005, 12:26 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 123 Joined: 5-September 05 Member No.: 11,522 |
It looks like your code is valid and should work. On what kind of server are you running this script? (i.e., Linux, Windows, et cetera) You may simply have a permissions problem that either you or the server administrator needs to change. That's all of which I can think!
Hope this helps!! |
|
|
|
Sep 26 2005, 05:23 AM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
Try changing $uploadDir = '/uploads/'; to $uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
As it is now, PHP will try and copy the uploaded file into the '/uploads' directory on the root of the server - not the root of your site, which is probably something like '/www/username/public_html/'. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 8th September 2008 - 09:01 AM |