Page 1 of 1

Process file is accessed twice

Posted: Sat Mar 22, 2008 4:30 pm
by dstonek
V2.0
I found that each time a file is uploaded the process file is accessed twice.
The first time no vars are posted. In my case it causes that Apache generates 4 error messages/upload. Have an idea when users upload hundreds of files...
The second time is the regular one.
Here are some parameters from applet_http.js:

Code: Select all

document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="scriptable" VALUE="true">');
document.writeln('<PARAM NAME="url" VALUE="http://domain.com/process-upload.php">');
document.writeln('<PARAM NAME="paramfile" VALUE="uploadfile">');
document.writeln('<PARAM NAME="param1" VALUE="todo">');
document.writeln('<PARAM NAME="value1" VALUE="upload">');
document.writeln('<PARAM NAME="mode" VALUE="http">');
document.writeln('<PARAM NAME="param7" VALUE="codigo">');
document.writeln('<PARAM NAME="value7" VALUE="DATA">'); 
document.writeln('<PARAM NAME="filter" VALUE="jfileupload.upload.client.filter.ImageFilter">');
How can this be solved?
Thank you

Re: Process file is accessed twice

Posted: Sun Mar 23, 2008 7:52 pm
by support
Are you using "resume" or "overwrite" parameter ? Because such parameter make the applet send a first request before upload.

Re: Process file is accessed twice

Posted: Mon Mar 24, 2008 2:17 pm
by dstonek
document.writeln('<PARAM NAME="resume" VALUE="true">');
Is it possible to send a post var only within this first request?
If so, I can state an 'if', ask for it and skip the file process to avoid these error msgs.Thxs

Re: Process file is accessed twice

Posted: Mon Mar 24, 2008 2:20 pm
by support
No, because "post" follows a successful upload. So, upload need to be completed before sending post request. However, for "resume", the applet send a HTTP HEAD request, not POST so you could filter or test the HTTP method.

Does it help ?

Re: Process file is accessed twice

Posted: Mon Mar 24, 2008 4:25 pm
by dstonek
Nice!
Thank you.

Code: Select all

if ($_SERVER['REQUEST_METHOD'] != 'HEAD'){
// process here
}