AscIId Posted June 9, 2007 Share Posted June 9, 2007 hi everyone i am trying to move an image to a directory and i am having no luck. i am working on this as a separate project to the other one i posted about because i have made a lot of progress as far as layout is concerned and the other project is supposed to be a secret anyway... here are the errors i get Warning: move_uploaded_file(/public_html/a/upload/0) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/me/public_html/a/insert.php on line 16 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php9U9t8g' to '/public_html/a/upload/0' in /home/me/public_html/a/insert.php on line 16 I have tried different permitations of the directory such as /upload/, /a/upload/ and /public_html/a/upload/ but still have no luck. the directories are CHMOD'd to 777 here is my source code <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("a", $con); $photoName = @mysql_insert_id(); //use the insert ID as the photo name in a specific folder on your site $newDest = '/upload/'.$photoName; move_uploaded_file($_FILES["file"]["tmp_name"],$newDest); $sql="INSERT INTO person (FirstName, LastName, Age ) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "record added"; mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/54865-moving-an-image/ Share on other sites More sharing options...
penguin0 Posted June 9, 2007 Share Posted June 9, 2007 try $newDest = './upload/'.$photoName; Link to comment https://forums.phpfreaks.com/topic/54865-moving-an-image/#findComment-271493 Share on other sites More sharing options...
Trium918 Posted June 9, 2007 Share Posted June 9, 2007 Try! http://www.w3schools.com/php/php_file_upload.asp Link to comment https://forums.phpfreaks.com/topic/54865-moving-an-image/#findComment-271512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.