|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_eoffice/application/bin/auction_news/ |
Upload File : |
// JavaScript Document
$(document).ready(function(){
$("#Upload").click(function(){
if($("#fileToUpload").val()==""){
alert("กรุณาเลือกไฟล์ก่อน");
return false;
}
ajaxFileUpload("ADD","")
})
})
function ajaxFileUpload(state,id)
{
//if(state=="LOAD"){
document.form.Fstatus.value=state;
document.form.chkedit.value=id;
// }
var ElementIdArray= new Array(3)
ElementIdArray[0]={Name:"fileToUpload",Type:"File"}
ElementIdArray[1]={Name:"idindex",Type:"Hidden"}
ElementIdArray[2]={Name:"Fstatus",Type:"Hidden"}
ElementIdArray[3]={Name:"chkedit",Type:"Checkbox"}
$("#loading")
.ajaxStart(function(){
$(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});
$.ajaxFileUpload
(
{
url:'doajaxfileupload.php',
secureuri:false,
ElementId:ElementIdArray,
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
document.getElementById('UploadStatus').innerHTML=data.error;
}else
{
Showlistitem( data.msg);
document.form.desc.value=id;
}
}
},
error: function (data, status, e)
{
alert( status + " "+data.responseText)
}
}
)
return false;
}
function Showlistitem(ListItem)
{
var str="";
for(i=0;i<ListItem.length;i++){
str+= "<ul>"+(i+1)+". "+ ListItem[i].desc +" <a href='#'> <img border=0 src=\"../../../images/b_drop.png\"/ onClick=\"DELFile('"+ ListItem[i].id +"')\"></a></ul>"
}
document.getElementById('listFile').innerHTML=str;
}
function DELFile(ID){
if(confirm('ต้องการลบรูปนี้หรือไม่')){
ajaxFileUpload('DEL',ID)
}
}