drkshenronx Posted December 13, 2007 Share Posted December 13, 2007 I keep getting this error when i try to upload the files onto my server Warning: move_uploaded_file(images) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\freemmorpg\check_image.php on line 17 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'c:/wamp/tmp\php18A.tmp' to 'images' in C:\wamp\www\freemmorpg\check_image.php on line 17 This is the html form to submit the image <html> <head> <title>Add A Screenshot</title> </head> <body> <form name="upload" method ="post" action="check_image.php" enctype="multipart/form-data"> <table cellpadding="5"> <tr> <td>Screenshot Caption <br> <em> Example: big man, ghost pilot </em></td> <td><input name="image_caption" type="text" id="image_caption" size="15" maxlength="255"></td> </tr> <td>Username<br> <em> Example: joe123,, marty_marshin </em></td> <td><input name="image_username" type="text" id="image_username" size="15" maxlength="255"></td> </tr> <td>Upload Image <br> </td> <td><input name="image_filename" type="file" id="image_filename"></td> </tr> </table> <em> Acceptable image formats include: GIF, JPG/JPEG, and PNG. </em> <p align="center"><input type="Submit" value="Submit"> <input type="reset" name="Submit2" value="Clear Form"> </p> </form> </body> </html> This is the script to check the image (check_image.php) <?php $con = mysql_connect('localhost', 'forums', 'password') or die ("could not connect:" . mysql_error()); mysql_select_db("screenshots", $con) or die (mysql_error()); $image_caption = $_POST['image_caption']; $image_username = $_POST['image_username']; $image_tempname = $_POST['image_filename']; $today = date("Y-m-d"); $ImageDir = "images"; $ImageName = $ImageDir . $image_tempname; if (move_uploaded_file($_FILES['image_filename']['tmp_name'],$ImageName)) { list($width, $height, $type, $attr) = getimagesize($ImageName); switch ($type) { case 1: $ext = ".gif"; break; case 2: $ext = ".jpg"; break; case 3: $ext = ".png"; break; default: echo "Sorry, but the file you are trying to upload is not a valid Image <br>"; } // insert the image into the table $insert = "INSERT INTO images (image_caption, image_username, image_date) VALUES ('$image_caption', '$image_username', '$today')"; $insertresults = mysql_query($insert) or die(mysql_error()); $lastpicid = mysql_insert_id(); $newfilename = $ImageDir . $lastpicid . $ext; rename($ImageName, $newfilename); } ?> Please help!! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 13, 2007 Share Posted December 13, 2007 first of all I think $ImageDir = "images"; should be $ImageDir = "images/"; secondly is this directory chmod set to 777 ? Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 13, 2007 Author Share Posted December 13, 2007 no i didnt set the directory to chmod 777 ... how do i do this using windows ? Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 13, 2007 Author Share Posted December 13, 2007 no i didnt set the directory to chmod 777 ... how do i do this using windows ? I am using wamp server. if that helps. Quote Link to comment Share on other sites More sharing options...
FallenFighter420 Posted December 13, 2007 Share Posted December 13, 2007 It depends if the folder is on a server or not. If its on a server, cPanel or Direct Admin should have a little box after all the files that says "Chmod:" then a box. Put the 777 in that box, and select the folder you want too apply the setting too, and click, OK, or something. If not, and you're using Xamp, or Wamp, then it should do it automatically for you..it did with me. Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 13, 2007 Author Share Posted December 13, 2007 I am assuming that wamp didnt already set the chmod ... can anyone help me do this?? Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 13, 2007 Author Share Posted December 13, 2007 Umm guys ... by the way chmod is only a linux command isnt it ??? so isnt it useless on a windows box .... so i think fallen fighter was right i should be able to do it regardless because all windows files and folders are set to writable when you create them. Anyone else have any ideas ??? Quote Link to comment Share on other sites More sharing options...
FallenFighter420 Posted December 13, 2007 Share Posted December 13, 2007 No, it's not a Linux only command. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 13, 2007 Share Posted December 13, 2007 $image_tempname = $_POST['image_filename']; where is this coming from I do not see any input box in the form for this and its use to create the filename for the move ? Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 13, 2007 Author Share Posted December 13, 2007 <td>Upload Image <br> </td> <td><input name="image_filename" type="file" id="image_filename"></td> </tr> </table> <em> Acceptable image formats include: GIF, JPG/JPEG, and PNG. </em> <p align="center"><input type="Submit" value="Submit"> <input type="reset" name="Submit2" value="Clear Form"> Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 13, 2007 Author Share Posted December 13, 2007 This was the problem .. i figured it out $ImageDir = "images/screenshots"; $ImageName = $ImageDir . $image_tempname; I never declared the filename afterward the screenshots directory. Because of $ImageName = $ImageDir . $image_tempname; I am supposed to supply the name to name all of my images. silly me .. that was my bad ... everything else was fine though. Thanks for looking!! 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.