実際のアップロード処理PHPページに、アップロードされたファイルのファイル名で応答させる必要があります。
fengcoolのajaxでは、startUpload()関数で次のように提供されます。
var response = $(myFrame.contentWindow.document.body).text();
ファイル名を入力する必要がある場合は常に、その「応答」変数を使用します。
これは実際には変数「image」としてaddUpload()関数に渡されます。この関数は、おおよそ次のように、テキストボックスに入力するように変更できます。
document.getElementById( "image")。value = image
<input>
ただし、混乱を避けるために、一般的ではない方法で名前を付ける必要があります。
更新、何をすべきか:
1)テキストボックスにもっとユニークな方法で名前を付けます。例:
<input id="uploaded_image_name" type="text" value="" />
// Javascript関数getElementById()を使用できるようにするために、「name」ではなく「id」を使用したことにも注意してください。
2)fengcoolのajaxを使用し、関数addUpload()を次のように変更します。
function addUpload(id,img){
var div = $(document.createElement('div')).attr('id',id);
//add uploaded image
div.html("<img src='"+img+"'><br />");
document.getElementById("uploaded_image_name").value=img
//add text box
var fileName = img.substring(img.lastIndexOf("/")+1);
var txtbx = $(document.createElement('input')).attr('name','img[]').attr('type','text').val(fileName);
/* you may want to change textbox to a hidden field in production */
//var txtbx = $(document.createElement('input')).attr('name','img[]').attr('type','hidden').val(fileName);
txtbx.appendTo(div);
//add remove thumbnail link
var rem = $(document.createElement('a'))
.attr('alt',id)
.attr('href','javascript:;')
.text("Remove").click(removeUpload);
rem.appendTo(div);
//add to the page
div.appendTo("#uploaded_thumb");
}
唯一の変更は、関数に4番目のコマンドを追加したことであることに注意してください。