Jump to content

Moving an Image....


AscIId

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.