[Solved] Use javascript fct instead of url_post

XUpload related questions

Moderator: admin

Message
Author
cyriltra
Posts: 5
Joined: Jul 02, 2007 7:40 pm

[Solved] Use javascript fct instead of url_post

#1 Postby cyriltra » Jul 25, 2008 10:00 am

Hello,

once the upload is completed, how can i call a javascript function (parameters will be the file name, size etc..) instead of posting the values to a php/cgi script ?

I'm using the latest pro version.

Thank you for your help
Kind Regards,
Cyril
Last edited by cyriltra on Jul 26, 2008 7:13 am, edited 1 time in total.

User avatar
PilgrimX182
Posts: 2182
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#2 Postby PilgrimX182 » Jul 25, 2008 11:14 am

In upload.cgi find thi part of code

Code: Select all

   print"<HTML><BODY><Form name='F1' action='$url_post' target='_parent' method='POST'>";
   for my $f (@files)
   {
       print"<textarea name='$_\[]'>$f->{$_}</textarea>" for @file_fields;
   }
   print"<textarea name='$_->{name}'>$_->{value}</textarea>" for @har;
   print"</Form><Script>document.location='javascript:false';document.F1.submit();</Script></BODY></HTML>";


and replace it with

Code: Select all

print"<HTML><BODY><Script>";
for my $f (@files)
{
   print"window.parent.my_func('$f->{file_name}','$f->{file_name_orig}','$f->{file_size2}','$f->{file_size}','$f->{file_status}');";
}
print"</Script></BODY></HTML>";


where my_func is your function defined on upload page.

cyriltra
Posts: 5
Joined: Jul 02, 2007 7:40 pm

#3 Postby cyriltra » Jul 26, 2008 7:13 am

Thanks a lot PilgrimX182, it works perfectly :)

Cyril

giorrrgio
Posts: 8
Joined: Aug 04, 2008 11:11 am

#4 Postby giorrrgio » Aug 19, 2008 3:41 pm

The javascript way it's ok, even with ajax calls, but I have an issue:
even after upload has finished I keep on receiving upload_status.cgi traffic (I found that with firebug). I guess I should manually stop that with some explicit javascript function calls.
Thanks

User avatar
PilgrimX182
Posts: 2182
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#5 Postby PilgrimX182 » Aug 20, 2008 6:34 am

Try to add this before

Code: Select all

print"</Script></BODY></HTML>";


Code: Select all

window.parent.frames['transfer'].location='blank.html';
window.parent.frames['transfer2'].location='blank.html';

this will reload progress bar iframes and stop ajax requests.


Return to “XUpload”

Who is online

Users browsing this forum: No registered users and 0 guests