if (isset($_POST["submit"])){ // 1. check if photo is good (format/size in mb/size in px) if (($_FILES["file"]["type"] == "image/jpeg") && ($_FILES["file"]["size"] < 30000000)){ if ($_FILES["file"]["error"] > 0){ echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { // 2. connect db $con = mysql_connect("localhost","aaa","bbb"); if (!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); // 3. get photo id from db "gallery" $send=mysql_query("INSERT INTO pictures (id, date_uploaded) VALUES (NULL, now())"); $id=mysql_insert_id(); // 4. create file id. $filename = $_FILES["file"]["name"]; $file_ext = substr($filename, strripos($filename, '.')); // strip name $newfilename = $id . $file_ext; $path="temp/" . $newfilename; // temporary save it if (move_uploaded_file($_FILES["file"]["tmp_name"], $path)){echo "success";} else {echo "fail";} // <-- error is here / ошибка здесь? } } else { echo "Problems with photo."; } } 

I can not understand why it does not save the file ...

  • Put a minus for "Title for attention." - Oleg Arkhipov
  • Crash dopomіg bi - Taras Lukavy
  • To help you, formulate the question normally with an indication of errors, a detailed description of the problem. Look at the search, even by the upload tag you can search for your problem. - Dex

1 answer 1

If the error does not display, most likely the rights are incorrectly set. Be sure to check if the rights to write files to the specified directory are set.

  • And what should they be? Were 0755 replaced by 0775 - Taras Lukavy
  • Even worse. Directly. Nicole would not have wondered without you))) - Taras Lukavy