我正在使用AJAX創建設置嚮導。這是一個多步驟表單提交,共有6個步驟。步驟1-5工作正常,他們只是表單域,只提交文本。最後一步,第6步,將允許用戶上傳7個圖像。這一步不起作用。 I get a 500 Internal Server Error
通過AJAX傳輸圖片
我是否通過JSON正確傳遞圖像數據?還有什麼我做錯了或忘記?
相關的代碼如下:
HTML(對於步驟6只)
<form action="/ajax/wizard.php/<?php echo $userName ?>?step=3"
class="defaultRequest" enctype="multipart/form-data" method="post">
<input type="hidden" name="token" value="<?php echo $token; ?>"/>
<fieldset>
<p><label>Profile Picture</label>
<input type="file" name="pPic" value="" /></p>
<p><label><a href="#help-username" class="show_helper"><span>(?)</span>
Pic 1</a></label> <input type="file" name="Album1" value="" />
</p>
<p><label><a href="#help-password" class="show_helper"><span>(?)</span>
Pic 2</a></label><input type="file" name="Album2" value="" />
</p>
<p><label>Pic 3</label>
<input type="file" name="Album3" value="" /></p>
<p><label>Pic 4</label>
<input type="file" name="Album4" value="" /></p>
<p><label>Pic 5</label>
<input type="file" name="Album5" value="" /></p>
<p><label>Pic 6</label>
<input type="file" name="Album6" value="" /></p>
</fieldset>
<fieldset>
<p><label> </label>
<button type="submit"><span>Upload Images</span></button></p>
</fieldset>
JS
$.ajax({
type: 'POST',
url: requestUrl,
data: $(this).serialize(),
dataType: 'json',
success: function(data) {
if(data.response){
$('div.errormsg').remove();
$(eventHeadline).html(data.eventHeadline);
console.log(data.eventHeadline);
//$(eventDate).html(data.eventName);
if(data.step){
openStep(data.step);
}else{
openStep('next');
}
}else{
$('div.errormsg').remove();
$('<div class="errormsg">'+data.message+"</div>").insertBefore(form);
}
http://www.9lessons.info/2011/08/ajax-image-upload-without-refreshing.html – 2012-08-08 06:53:03
@Pushpesh - 謝謝你鏈接! – 2012-08-08 07:01:35