0
我有一個非常基本的Web應用程序運行,我只需要能夠上傳文件到數據庫(並將文件放入一個單獨的文件夾)。PHP/MySQL上傳不起作用
我已經剝離了代碼到裸露的骨頭嘗試讓它工作,但上傳功能失敗。
有誰知道它可能會出錯哪裏?
注意:我已經刪除了數據庫用戶名等,但它完美地連接在一起。
與表單頁面:
<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的 **** ****編輯可惜 仍無法正常工作......
<?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.";
}
?>
謝謝!! !
你的意思'UPDATE'的文件夾的權限?爲什麼在插入的WHERE條款 – Ghost
你的if語句應該是move_uploaded_file($ _ FILES ['file'] ['tmp_name'],$ target)? –
@Ghost - 它只是將它插入該行...有沒有更好的方法? – Scott