ded Posted October 20, 2008 Share Posted October 20, 2008 The picture is not loading to the folder....the following error appears: Error: Photo did not upload properly. Try again. echo "<form action=\"post.php\" method=\"post\">"; echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\">"; echo "File to Upload:<input name=\"filename\" type=\"file\"><br><br>"; echo "<input type=\"submit\">"; echo "</form></center>"; $uploaddir = '../../pictures/'; $filename = $_FILES['filename']['name']; $path = $uploaddir . $filename; echo '<pre>'; if (move_uploaded_file($_FILES['filename']['tmp_name'], $path)) { echo "Photo has been uploaded to database"; } else { echo "Error: Photo did not upload properly. Try again."; } print "</pre>"; Any help would be great..... Regards, DED Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/ Share on other sites More sharing options...
MatthewJ Posted October 20, 2008 Share Posted October 20, 2008 Check that the permissions on the folder you are uploading to are correct. Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670424 Share on other sites More sharing options...
graham23s Posted October 20, 2008 Share Posted October 20, 2008 cab you echo $path to see what it shows Graham Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670425 Share on other sites More sharing options...
ded Posted October 20, 2008 Author Share Posted October 20, 2008 Permissions are set at 777 Error: Photo did not upload properly. Try again. path = ../../pictures/ Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670431 Share on other sites More sharing options...
PFMaBiSmAd Posted October 20, 2008 Share Posted October 20, 2008 Use php full error reporting to get php to tell you why a function call failed. Add the following two lines immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670433 Share on other sites More sharing options...
ded Posted October 20, 2008 Author Share Posted October 20, 2008 Excellent.....thank you. I am getting this: Notice: Undefined index: filename in /home/site1/public_html/site2/admin/homepage/post.php on line 13 Notice: Undefined index: filename in /home/site1/public_html/site2/admin/homepage/post.php on line 16 Error: Photo did not upload properly. Try again. Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670435 Share on other sites More sharing options...
kenrbnsn Posted October 20, 2008 Share Posted October 20, 2008 You need enctype="multipart/form-data" in your <form> tag: <?php echo '<form action="post.php" method="post" enctype="multipart/form-data">'; echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000">'; echo 'File to Upload:<input name="filename" type="file"><br><br>'; echo '<input name="submit" type="submit">'; echo '</form></center>'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670442 Share on other sites More sharing options...
ded Posted October 20, 2008 Author Share Posted October 20, 2008 Your getting me there.....It finally recognizes the filename, but now I am receiving the following: Warning: move_uploaded_file(http://www.website.com/pictures/image.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in /home/site1/public_html/site2/admin/homepage/post.php on line 16 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpd8e2UR' to 'http://www.website.com/pictures/image.jpg' in /home/site1/public_html/site2/admin/homepage/post.php on line 16 Error: Photo did not upload properly. Try again. ../../pictures/image.jpg I have not a clue what this all means..... Thanks again to everyone for the help. DED Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670452 Share on other sites More sharing options...
PFMaBiSmAd Posted October 20, 2008 Share Posted October 20, 2008 You are using a URL to specify the destination, and as the error message states, HTTP cannot write files. You need to use a file system path to specify the destination. Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670464 Share on other sites More sharing options...
ded Posted October 20, 2008 Author Share Posted October 20, 2008 Yeah......I got it....changed the path back to ../../pictures and it works fine. Again, thank you all for the help. DED Quote Link to comment https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.