This application must upload in the server and write the image name in db table but not write, why, where I mistake? I have problems with the application? <?php include('conexiune.php'); $target = "imagini/"; $target = $target . basename( $_FILES['imagine']['name']); $pic=($_FILES['imagine']['name']); mysql_query("INSERT INTO imagine VALUES (id, imagine) VALUES(0, '$pic',"); if(move_uploaded_file($_FILES['imagine']['tmp_name'], $target)) { echo "Image upload was successful"; } else { echo "Sorry, but the image could not be uploaded on the server"; } ?> Code (markup): Or anyone knows a script that load the image on the server and saved name in the database? Thanks in advance. Best Regards, Floriano
Is this line is correct? mysql_query("INSERT INTO imagine VALUES (id, imagine) VALUES(0, '$pic',"); If it is, then you should remove the last comma and close it with ) mysql_query("INSERT INTO imagine VALUES (id, imagine) VALUES(0, '$pic')");
try this one <?php include('conexiune.php'); $target = "imagini/"; $target = $target . basename( $_FILES['imagine']['name']); $pic=($_FILES['imagine']['name']); mysql_query("INSERT INTO imagine (id, imagine) VALUES (0, '$pic')"); // look at this if(move_uploaded_file($_FILES['imagine']['tmp_name'], $target)) { echo "Image upload was successful"; } else { echo "Sorry, but the image could not be uploaded on the server"; } PHP:
Thanks very much "crivion" for help, is work now(is good, upload image) but another question, now not intro date in table: name, location, number If someone can help me Thank in advance, Floriano
"bai nenea, invata php" <?php include('conexiune.php'); $target = "imagini/"; $target = $target . basename( $_FILES['imagine']['name']); $pic=($_FILES['imagine']['name']); mysql_query("INSERT INTO imagine (id, imagine, name, location, number) VALUES (0, '$pic', '$_POST[name]', '$_POST[location]', '$_POST[number]')"); if(move_uploaded_file($_FILES['imagine']['tmp_name'], $target)) { echo "Image upload was successful"; } else { echo "Sorry, but the image could not be uploaded on the server"; } ?> <form enctype="multipart/form-data" action="upload.php" method="POST"> <BR>Nume: <BR><INPUT TYPE="TEXT" NAME="name"> <BR>Location: <BR> <INPUT TYPE="TEXT" NAME="location"> <BR>Number: <BR><INPUT TYPE="TEXT" NAME="number"> Imaginea: <input type="file" name="imagine"> <input type="submit" value="Upload"> </form> <br /> PHP: