-1
我jQuery代碼是:插入記錄和圖片用PHP和jQuery
$.post('action/edit_breakdown.php', {id: id,program: program,st_name: st_name,p_name: p_name,fob_name: fob_name,track_no: track_no,date: date,currency: currency,image_name: image_name},
function(data){
$("#message").html(data);
//$("#editBreakdown").attr('disabled','disabled');
$("#message").hide();
$("#message").fadeIn(1500); //Fade in the data given by the insert.php file
/*$('#editBreakdown').each(function(){
setTimeout(function() { window.location.reload(true); }, 2000);
});*/
});
插入記錄我所使用的操作頁面,如:
<?php
require_once("../config/dbConnect.php");
$image_name=$_FILES['image_name']['name'];
$tmpName=$_FILES['image_name']['tmp_name'];
if($image_name)
{
/*$photo=$_FILES['photo']['name'];
$tmpName=$_FILES['photo']['tmp_name'];*/
$ext=substr(strchr($image_name,"."),1);
$rand = mt_rand(100000, 999999);
$image_name=$rand.".".$ext;
$filePath="pictures/".$photo;
//echo "this is ".$filePath;
$result=move_uploaded_file($tmpName,"../".$filePath);
thumbnail("../pictures", "../pictures","$image_name",200,$ext);
}
echo $BreakdownUpdate = "UPDATE breakdowns SET image='$filePath' WHERE id='$id'";
$query = mysql_query($BreakdownUpdate) or die(mysql_error());
if($query)
{
echo "<div class='oMsg1 oMsgError1'>Breakdown successfully Updated </div>";
}
else
{
echo "<div class='oMsg oMsgError'>Breakdown Update failed,Try again </div>";
}
?>
我的問題是,這個代碼顯示在下面的錯誤:
未定義指數:IMAGE_NAME在C:\ XAMPP \ htdocs中\ Marchand的\動作\上線edit_breakdown.php 1
我該如何解決這個問題?
但請參閱上面的jQuery代碼,是否有任何可能的方式插入圖像與我的代碼? – 2013-05-05 08:12:18
是啊,我想上傳一個文件 - @ bjelli ....... – 2013-05-05 08:18:00
@Amit,是的,你可以。在bjelli鏈接的頁面中,似乎有一種新的方式來處理事情(僅限HTML5,您需要查看瀏覽器覆蓋率是否可以接受)或使用jQuery插件。後者不是AJAX,而是看起來差不多。按照該頁面上的說明之一,看看它是否適合你! – halfer 2013-05-05 09:42:09