Anyone know how to send this via ajax?
This is pandastream's pandauploader . Except I want it to be sent via AJAX. Anyone know how I would convert this?
:javascript
$("#returned_video_id").pandaUploader(#{Panda.signed_params('post', "开发者_Python百科/videos.json", :profiles => 'f1eb0fe2406d3fa3530eb7324f410789').to_json}, {
onsuccess: function(){
$(".opened_photo").fadeTo(200, 0, function() {
$(".opened_photo").hide();
$(".media_lib").fadeIn();
});
},
upload_progress_id: "upload_progress",
allowed_extensions: ['AAC', 'AVI', '3GP', 'FLV', 'MOV', 'MP3', 'MP4', 'MPEG', 'OGG', 'WAV', 'WEBM', 'WMA', 'WMV',
'aac', 'avi', '3gp', 'flv', 'mov', 'mp3', 'mp4', 'mpeg', 'ogg', 'wav', 'webm', 'wma', 'wmv']
});
multipart/form-data
file uploads cannot be sent via XMLHttpRequest. This is because the request body is always sent as a String, encoded as UTF-8. You can't send raw binary.
If you write a custom upload receiver to expect it you can encode the file content inside text using a scheme like base-64. But this will make the upload larger (and thus slower), and in any case you can only read files from JavaScript on browsers that support the new File API.
I don't know about ‘pandastream’, but HTML file upload without page reload is usually done by posting a form with a target
pointed at an <iframe>
, for this reason.
(Incidentally, allowed_extensions
isn't really a good idea. Apart from missing case possibilities and other missing possible extensions, on non-Windows platforms, filetype may have nothing to do with extension.)
精彩评论