PDA

View Full Version : Form file upload response problem (IE)



Air_Mike
16 Oct 2007, 5: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
16 Oct 2007, 6:18 AM
file uploads are browser submits, not Ajax submits. The response must be something that a browser can understand.

Air_Mike
16 Oct 2007, 6: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
16 Oct 2007, 9:34 AM
Try searching the forums - there are a number of threads with some pretty lengthy discussions/examples.

Air_Mike
16 Oct 2007, 11:38 AM
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
16 Oct 2007, 10:47 PM
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
25 Oct 2007, 3: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
1 Feb 2008, 10:34 AM
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