Note that there are some explanatory texts on larger screens.

plurals
  1. POScript not uploading photo
    primarykey
    data
    text
    <p>Ok so I have a script that takes data from a form inserts into database and uploads the picture, its inserting all the information into the database but not uploading the picture.</p> <p>The code is below, I am quite new to PHP so your advice is greatly appreciated.</p> <p>Thank you :-)</p> <pre><code>//This is the directory where images will be saved $target = "../restaurants/images/"; $target = $target . basename( $_FILES['photo']); //This gets all the other information from the form $rest_name=$_POST['rest_name']; $address1=$_POST['address1']; $address2=$_POST['address2']; $town=$_POST['town']; $postcode=$_POST['postcode']; $open_time=$_POST['open_time']; $halal=$_POST['halal']; $deliver_areas=$_POST['deliver_areas']; $deliver_time=$_POST['deliver_time']; $type=$_POST['type']; $photo=($_FILES['photo']); mysql_select_db(restaurants); //Writes the information to the database mysql_query("INSERT INTO `restaurants` VALUES ('', '$rest_name', '$address1', '$address2', '$town', '$postcode', '$open_time', '$halal', '$deliver_areas', '$deliver_time', '$type', '$photo')") ; if( mysql_errno() != 0){ // mysql error // note: message like this should never appear to user, should be only stored in log echo "Mysql error: " . htmlspecialchars( mysql_error()); die(); } //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok header('Location: add-restaurant.php?added'); } else { //Gives and error if its not header('Location: add-restaurant.php?fail'); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload