通过jQuery发送文件信息的话,被PHP脚本

问题描述:

处理,我不知道这甚至有可能,但这里是我到目前为止有:通过jQuery发送文件信息的话,被PHP脚本

<input type="file" name="image" id="image_upload" /> 
<button id="submit" /> 
<div id="display"></div> 

这里的jQuery的,但是这是发送作为POST数据,当然它实际上并没有获取文件信息,据我所知。有没有办法通过AJAX发送到我的upload.php脚本?

// Send ajax data to create option in store 
$('#submit').live('click', function() { 
    var file = $('#image_upload').val(); 
    $.ajax({ 
     type: "POST", 
     url: "upload.php", 
     data: "file="+file, 
     success: function(html){ 
      $('#display').html(html); 

     } 
    }); 
}); 

你应该签http://www.uploadify.com/,重新发明轮子(尤其是这轮)往往是乏味和将肯定让你感到沮丧。

为了进一步说明这一点,目前不可能通过XMLHttpRequest(aka AJAX)上传文件。你可以用许多不同的方法来伪造它(例如POST到一个iframe),这实际上可以做得很好。

祝你好运!

编辑:

http://valums.com/ajax-upload/

+0

是的,基于Flash的选项是不可行的我在做什么:

不使用闪光灯

解决方案。 – kylex 2011-03-18 22:01:20

+0

更新回答提供非Flash解决方案。 – 2011-03-18 22:03:55