Hi!
I use the prototype javascript library for my ajax calls... how would I could configure the script to call a js script instead of a redirect after the file has finished uploading?
Pere
XUpload - JS call instead of redirect?
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
It is possible.
I guess you're using FREE version. Here goes hack: in upload.cgi replace
with
haven't tested something like this, but should work.
I guess you're using FREE version. Here goes hack: in upload.cgi replace
Code: Select all
### Sending data with POST request if required
my $url_post = $cg->param('url_post');
$url_post ||= $c->{url_post};
if($url_post)
{
my ($str,@har);
for (0..$#fileslots)
{
push @har, { name=>$fileslots[$_], 'value'=>$filenames[$_] };
push @har, { name=>"$fileslots[$_]_status", 'value'=>$file_status[$_] };
}
for my $k (@params)
{
my @arr = $cg->param($k);
for my $p (@arr)
{
next if ref $p eq 'Fh'; #&& $p !~ /\.$c->{ext_allowed}$/i; # Skip unallowed files
$p =~ s/.*\\([^\\]*)$/$1/;
push @har, { name=>$k, value=>$p };
}
}
push @har, { name=>'target_dir', value=>$c->{target_dir} };
print"<HTML><BODY onLoad='document.F1.submit();'><Form name='F1' action='$url_post' target='_parent' method='POST'>";
print"<textarea name='$_->{name}'>$_->{value}</textarea>" for @har;
print"</Form></BODY></HTML>";
exit;
}
### Upload finished, redirecting
my $redirect_link = $cg->param('redirect_link');
$redirect_link ||= $c->{redirect_link};
print"<HTML><Script>parent.document.location='$redirect_link';</Script></HTML>";
Code: Select all
print"<HTML><Script>parent.YOURJSFUNCTION();</Script></HTML>";
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Thanks!
In Pro version you need to replace
with
In Pro version you need to replace
Code: Select all
### Sending data with POST request if need
.......
print"Content-type: text/html\n\n";
print"Upload complete.";
Code: Select all
print"Content-type: text/html\n\n";
print"<HTML><Script>parent.YOURJSFUNCTION();</Script></HTML>";