kurios Posted August 8, 2008 Share Posted August 8, 2008 Anytime i upload a image, i get the following errors: Warning: move_uploaded_file(/var/chroot/home/content/k/u/r/kuriomister/html/images/png8.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/k/u/r/kuriomister/html/temp/update.php on line 143 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpbzDIHH' to '/var/chroot/home/content/k/u/r/kuriomister/html/images/png8.jpg' in /home/content/k/u/r/kuriomister/html/temp/update.php on line 143 and i cant seem to find out why anyone have any ideas, cause im running out (yes, my php is configured for uploading). Its on a shared linux host. HTML Code: <FORM ENCTYPE="multipart/form-data" ACTION="update.php" METHOD="post" name="upload" id="upload"> <INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000"> <B>Image:</B><BR> <INPUT TYPE="file" id="image" name="image" VALUE="" SIZE="60" MAXLENGTH="100"><BR> <BR> <BR> <INPUT TYPE="SUBMIT" VALUE="Upload Image"> </FORM> PHP code: [tt] <?php $error = ''; //test for error if ($_FILES['image']['error'] > 0) { switch ($_FILES['image']['error']) { case 1: $error = 'Error[1]: Size exeeded maximum file size allowed.<BR><BR><BR>'; case 2: $error = 'Error[2]: Size exeeded maximum file size allowed.<BR><BR><BR>'; case 3: $error = 'Error[3]: File only partially uploaded<BR><BR><BR>'; case 4: $error = 'Error[4]: No file uploaded<BR><BR><BR>'; } } if ($error == '') { $upfile = $_SERVER['DOCUMENT_ROOT'].'/images/'.$_FILES['image']['name']; if (is_uploaded_file($_FILES['image']['tmp_name'])) { if (!move_uploaded_file($_FILES['image']['tmp_name'], $upfile)) { $error = 'Error: Couldn\'t move file to destination directory<BR><BR><BR>'; } }else{ $error = 'Error: Image not uploaded'; } } if ($error == '') { echo '<IMG SRC="'.$DOCUMENT_ROOT.'/images/'.$_FILES['file']['name'].'"><BR>'; echo '<B>FILE UPLOADED:</B><BR><BR><HR><I>'.$_FILES["file"]["name"].'successfully uploaded<BR></I><HR><BR><BR>\n'; echo '<A HREF="eventimages.php">Add Another Image</A><BR>'; }else{ echo $error; } ?>[/tt] Quote Link to comment Share on other sites More sharing options...
btherl Posted August 8, 2008 Share Posted August 8, 2008 Does the images directory exist? Did you call it "image" instead of "images"? How about moving the uploaded file to another directory, does that work? Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted August 8, 2008 Share Posted August 8, 2008 when you move an uploaded file to a folder, you start with the folder name, not a "/" and you dont need any document root stuff. so go from: $upfile = $_SERVER['DOCUMENT_ROOT'].'/images/'.$_FILES['image']['name']; to $upfile = 'images/'.$_FILES['image']['name']; This is bc the move_uploaded_file moves relative to the current position. So if you root folder is public_html and you have the upload script there, you can't do "move uploaded file to 'public_html/images/image.jpg' " because there is no folder called public_html in your public_html folder.(if that made sense) Quote Link to comment Share on other sites More sharing options...
kurios Posted August 8, 2008 Author Share Posted August 8, 2008 Thank you, it now works Quote Link to comment 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.