Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing PHP to upload an image and store data in MSSQL
    primarykey
    data
    text
    <p>I'm attempting to upload an image as well as add details such as; title, description and filepath into a database table.</p> <p>I'm using the following code, but it isn't adding any data to the database;</p> <p>(The session.php include contains the database connectivity.)</p> <pre><code>&lt;?php include('includes/session.php'); $uploadDir = 'submitted/pictures/'; if(isset($_POST['submit'])) { $fileName = $_FILES['file']['name']; $tmpName = $_FILES['file']['tmp_name']; $fileSize = $_FILES['file']['size']; $fileType = $_FILES['file']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading &lt;strong&gt;file&lt;/strong&gt;"; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $title = $_POST['title']; $description = $_POST['description']; $query = "INSERT INTO $user_pictures (file, title, description) VALUES ('$filePath', '$title', '$description')"; mssql_query($query); } ?&gt; </code></pre> <p>The form code;</p> <pre><code>&lt;form name="Image" enctype="multipart/form-data" action="upload-pics2.php" method="POST"&gt; Title &lt;input type="text" name="title" maxlength="100" class="textbox" value="&lt;?php echo $form-&gt;value("title"); ?&gt;" /&gt; Description &lt;textarea name="description" rows="8" cols="40" class="textbox" value="&lt;?php echo $form-&gt;value("description"); ?&gt;"&gt;&lt;/textarea&gt; File &lt;input type="file" name="file" accept="image/gif, image/jpeg, image/x-ms-bmp, image/x-png" size="26" class="textbox" /&gt; &lt;input type="submit" name="submit" value="Upload" class="button" /&gt; &lt;/form&gt; </code></pre> <p>I was wondering if someone could tell me what might be going wrong?</p> <p>Thank you.</p>
    singulars
    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.
 

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