View Full Version : Form file upload response problem (IE)
Air_Mike
10-16-2007, 09:50 AM
Hi,
I have question about file upload with form.
I made form for file upload together with some other data and everything work fine, accept I
have problem with response on IE.
My PHP script returns:
[PHP]echo '{success:true, message:"Uspje
Animal
10-16-2007, 10:18 AM
file uploads are browser submits, not Ajax submits. The response must be something that a browser can understand.
Air_Mike
10-16-2007, 10:31 AM
How come FF works just fine?
So when success fires, and what it expects.
How should I modify my form so it should work???
tryanDLS
10-16-2007, 01:34 PM
Try searching the forums - there are a number of threads with some pretty lengthy discussions/examples.
Air_Mike
10-16-2007, 03:38 PM
I searched forum and I found everything but the thing that could solve my problem.
I didn't mentioned that I'm using jQuery Ext.
I've tried with setting content-type to text/html and returning <html><textarea>{success:true, message:"test"}</textarea></html> but than I get error: missing parenthesis }
I saw something with updatemanager but i don't know how to put that in my example.
If just someone could tell me what php script should return??? IE is the problem, 'cause FF works fine.
Air_Mike
10-17-2007, 02:47 AM
I found this that Animal wrote:
You must send back an HTML document in response to a file upload. The response is sucked into an iframe document by the browser, and the innerHTML is scraped out to provide the responseText in a "faked" XHR object.
So if you must return a complex Json object, embed it in a <textarea> so that you can extract it from the faked responseText with a regex.
Ok, my php script return this:
$contentType = "text/html; charset=utf-8";
header("Content-Type: {$contentType}");
echo '<html><textarea>{success:true, message:"test"}</textarea></html>';
With this FF gives me error, but on IE, whatever I do or what ever response I give, failure or success just don't execute.
Please help...
Tnank You
sturdypine
10-25-2007, 07:33 AM
modify method decode of Ext.util.JSON to get rid of "<pre>" tag.
this.decode=function(json){var i=json.indexOf("<pre>");if(i>=0)json=json.substring(i+5);i=json.indexOf("<PRE>");if(i>=0)json=json.substring(i+5);i=json.indexOf("</pre>");if(i>=0)json=json.substring(0,i);i=json.indexOf("</PRE>");if(i>=0)json=json.substring(0,i);return eval("("+json+")")}})();
i gotta another problem,
upload works fine in FF, but fails in IE6.0.
IE can not send request to server.
onestream
02-01-2008, 01:34 PM
I had the same problem with the response for Ext.ux.UploadDialog - it was solved by the code from sturdypine, thought I'd clean it up a bit:
this.decode = function(json){
var i=json.indexOf("<pre>");
if(i>=0) {
json=json.substring(i+5);
}
i=json.indexOf("<PRE>");
if(i>=0) {
json=json.substring(i+5);
}
i=json.indexOf("</pre>");
if(i>=0) {
json=json.substring(0,i);
}
i=json.indexOf("</PRE>");
if(i>=0) {
json=json.substring(0,i);
}
return eval("("+json+")");
}
It should probably be solved by creating a valid html document rather than have it be modified by the browser. Also, regexps would be more safe...
Cheers,
onestream
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.