I've got a very basic web app running, and I just need to be able to upload files to the database (and place the file into a separate folder).
I've stripped down the code to the bare bones to try and get it working, but the upload function is failing.
Does anyone know where it could be going wrong?
Note: I've removed the DB username, etc here but it is connecting perfectly.
PAGE WITH FORM:
<form class="order-details" action="engineering/upload.php" method="post" enctype="multipart/form-data">
<input type="text" placeholder="Client / Customer Name" id="order_client" value="<?php echo $order_client ?>" name="order_client" />
<input type="hidden" placeholder="Order Number" id="order_no" value="<?php echo $order_no ?>" name="order_no" />
<input type="file" name="file">
<input type="submit" />
</form>
UPLOAD.PHP **** Edited **** Unfortunately still not working...
<?php
session_start();
ob_start();
define('DB_SERVER', 'localhost');
define('DB_USERNAME', '***');
define('DB_PASSWORD', '***');
define('DB_DATABASE', '***');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
$order_no = $_POST['order_no'];
$target = "/uploads/";
$pic=($_FILES['file']['name']);
$targetfinal = $target . basename( $pic );
$sql = "UPDATE orders SET order_files = '$pic' WHERE order_no = '".$order_no."' ";
mysql_query($sql);
if(move_uploaded_file($pic, $targetfinal)) {
header ("Location:/edit-order.php?orderid=".$order_no."&upload=success");
} else {
echo "Sorry, there was a problem uploading your file.";
}
?>
Thank you!!!