用這個卡住了,試過從ajax到w3schools上傳的版本,但沒有去。PHP上傳文件,保存文件的網址到MySQL
我_events.php腳本包含以下來獲取文件信息:
<input name="event_image" type="file" />
我_eventscreate.php腳本沒有文件上傳到我的_gallery /目錄的方式,上傳一次我想網址到要保存到我的數據庫的文件(請參閱SQL查詢)。
<?php // Get Event ID
$location=$_GET['location'];
// Get values from form
$event_name=$_POST['event_name'];
$event_description=$_POST['event_description'];
$event_date=$_POST['event_date'];
$event_time=$_POST['event_time'];
$event_cost=$_POST['event_cost'];
$event_image=$_POST['event_image'];
// Connection to MySQL Database.
include ('_includes/_dbconnection.php');
include ('_includes/_dbopen.php');
// Update Event using Event ID.
$sql="INSERT INTO b_events (ename, edescription, edate, etime, ecost, locationid, eimage)VALUES('$event_name', '$event_description', '$event_date', '$event_time', '$event_cost', '$location', '$event_image')";
$result=mysql_query($sql);
if($result){
header('Location: _events.php');
}
else {
header('Location: _home.php');
}
?>
請幫助
你能顯示你的ajax代碼嗎? – 2012-04-13 10:47:31
不確定你在做什麼,你可能需要使用$ _FILES http://php.net/manual/en/reserved.variables.files.php,你粘貼的代碼塊是由ajax處理的嗎? – encodes 2012-04-13 11:04:50