Upload script failure

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
ozzy214
-


Joined: 31 Mar 2006
Posts: 66

PostPosted: Sat Apr 01, 2006 7:34 pm    Post subject: Upload script failure Reply with quote

I keep getting this error with a perl uploader script. What tweaks can I get it to run?

CGI.pm: Server closed socket during multipart read (client aborted?).
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Apr 02, 2006 1:43 pm    Post subject: Re: Upload script failure Reply with quote

ozzy214,

What is the script name/download URL? Have you tried increasing the CGI Timeout value in Abyss Web Server (useful if the uploaded file is large and the connection is not very fast)?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
ozzy214
-


Joined: 31 Mar 2006
Posts: 66

PostPosted: Sun Apr 02, 2006 2:14 pm    Post subject: Reply with quote

It is fap which is full album mod for phbb. It uses nuffloader to upload the pics to the album and nuff is a cgi script.

It can be downloaded from http://www.mightygorgon.com/viewtopic.php?t=2553

Nuffloader was based on Radith's megaupload perl script

Hope this is enuff info....will try the timeout, but I doubt that's it. Since Im only uploading a pic about 3000 k
Back to top View user's profile Send private message
ozzy214
-


Joined: 31 Mar 2006
Posts: 66

PostPosted: Sun Apr 02, 2006 5:05 pm    Post subject: Reply with quote

# Author : Nuffmon 2005
# http://www.nuffmon.oftheweek.de
# Version 1.4.2
# Last Update 19/11/2005
#
# The Initial Developer of the Original Code is Raditha Dissanayake.
# Portions created by Raditha are Copyright (C) 2003
# Raditha Dissanayake. All Rights Reserved.


use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $qstring = "";

if (length ($ENV{'QUERY_STRING'}) > 0){
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$$name = $value;
$qstring .= "$name=$value&";
}
}
$psid =~ s/[^a-zA-Z0-9]//g;

$post_data_file = "tmp/" . $psid . "_postdata";
$monitor_file = "tmp/" . $psid . "_flength";
$qstring_file = "tmp/" . $psid . "_qstring";

$len = $ENV{'CONTENT_LENGTH'};
$bRead=0;
$|=1;

# Check for max upload size, set to whatever you want
if($len > 32000000)
{
close (STDIN);
print "Content-type: text/html\n\n";
print "<br>The maximum upload size has been exceeded<br>\n";
exit;
}

# Send content-length to monitor file
if (-e "$monitor_file") {
unlink("$monitor_file");
}
open (MF,">", "$monitor_file") or die "can't open monitor file";
print MF $len;
close (MF);
sleep(1);

# read and store the raw post data on a temporary file so that we can
# pass it though to a CGI instance later on.
if (-e "$post_data_file") {
unlink("$post_data_file");
}
open(TMP,">","$post_data_file") or &bye_bye ("can't open temp file");
my $i=0;
$ofh = select(TMP); $| = 1; select ($ofh);
while (read (STDIN ,$LINE, 4096) && $bRead < $len )
{
$bRead += length $LINE;
$i++;
print TMP $LINE;
}
close (TMP);

#
# We don't want to decode the post data ourselves. That's like
# reinventing the wheel. If we handle the post data with the perl
# CGI module that means the PHP script does not get access to the
# files, but there is a way around this.
#
# We can ask the CGI module to save the files, then we can pass
# these filenames to the PHP script. In other words instead of
# giving the raw post data (which contains the 'bodies' of the
# files), we just send a list of file names.
#

open(STDIN,"$post_data_file") or die "can't open temp file";
my $cg = new CGI();
my %vars = $cg->Vars;
my $j = 0;

while(($key,$value) = each %vars)
{
$file_upload = $cg->param($key);
if(defined $value && $value ne '')
{
my $fh = $cg->upload($key);
if(defined $fh)
{
$tmp_filename = "tmp/$psid"."_actualdata"."$j";
open(TMP,">","$tmp_filename") or &bye_bye ("can't open temp file");
while(<$fh>) {
print TMP $_;
}
close(TMP);
$fsize =(-s $fh);
$fh =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$tmp_filename =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$qstring .= "file[name][$j]=$fh&file[size][$j]=$fsize&";
$qstring .= "file[tmp_name][$j]=$tmp_filename&";
$qstring .= "file[field][$j]=$key&";
$j++;
}
else
{
$value =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$qstring .= "$key=$value&" ;
}
}
}

# Write query string to file.
if (-e "$qstring_file") {
unlink("$qstring_file");
}
open (QSTR,">", "$qstring_file") or die "can't open output file";
print QSTR $qstring;
close (QSTR);

# Tidy up after ourselves.
unlink("$monitor_file");
unlink("$post_data_file");

# OK lets get back to album upload.
my $url= $redirect . "?psid=$psid";
print "Location: $url\n\n";

Its also tied into a php script, but this is what the perl side looks like...
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Apr 03, 2006 12:38 pm    Post subject: Re: Upload script failure Reply with quote

ozzy214,

The error message you received seems to be quite common: http://www.google.com/search?q=%22Server+closed+socket+during+multipart+read%22 .

It should only occur when the server stops sending data to the CGI process because it timed out or because the client (the browser) disconnected during the upload.

But it seems also to appear when the uploaded file name is "malformed": http://rt.cpan.org/Public/Bug/Display.html?id=4108 .

Could you please try the upload with a smaller files? Could you test the timeout increasing suggestion?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
ozzy214
-


Joined: 31 Mar 2006
Posts: 66

PostPosted: Mon Apr 03, 2006 1:45 pm    Post subject: Reply with quote

I tried increasing timeout to no avail. Got it up to 300 secs. As far as the size Im only uploading pics bout 2 mb. That aint much.....
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Apr 04, 2006 8:13 pm    Post subject: Reply with quote

ozzy214 wrote:
I tried increasing timeout to no avail. Got it up to 300 secs. As far as the size Im only uploading pics bout 2 mb. That aint much.....

Could you try with files around which size is around 100 KB?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Kavkazzz
-


Joined: 16 May 2009
Posts: 17
Location: USA

PostPosted: Thu Aug 20, 2009 1:22 pm    Post subject: Upload script failure Reply with quote

Hi,

I have been using bformmail.pl in my web form for getting feedback, however I need to be able to get my users to upload attachments. Does bformmail.pl allow this as it isnt working ?

If not, is there another script I can use ?

Thanks in advance
-SPAM LINK REMOVED-
Back to top View user's profile Send private message Send e-mail ICQ Number
Axis
-


Joined: 29 Sep 2003
Posts: 336

PostPosted: Thu Aug 20, 2009 5:14 pm    Post subject: Reply with quote

Hello ozzy214--

I have a file upload script installed that works well. (On my site-- http://sixa.no-ip.info/upload.html )

You can download free (though they stick you with a 4 times a year newsletter) here:
http://www.perlservices.net/en/download/index.shtml --psupload

Hello Kavkazzz--

The above would allow you to get attachments alone but not with bformmail. I used bformmail for quite awhile but the recipients are always shown in the code so it is a spam collector. I would really suggest using dB Masters FormM@iler which is a simple two page php script. It hides recipients address and has a "sorta-CAPTCHA" to stop automatic submissions and says it supports attachments, though I don't use the attachment option on any of my sites. It is free if to use if (author quote) "FormM@iler is free to use provided I get credits in links on the form pages that use the script."

You can download this script here:
http://www.dbmasters.net/index.php?id=4

Regards,
Axis

I get zero spam with this script
Back to top View user's profile Send private message
martinscott
-


Joined: 22 Sep 2009
Posts: 1

PostPosted: Tue Sep 22, 2009 8:18 am    Post subject: hi Reply with quote

#!/usr/bin/perl

# Author: Bodo Eggert <7eggert@gmx.de>
# Status: pre-alpha
# License: GPL
# ObExcuse: This is my first perl script

#
# To use the script, make a subdirectory and save (or symlink)
# it there. This will be the script data directory.
# Adjust the path to your napshare temporary directory,
# any file not blacklisted and existing in that directory will be
# downloaded.
#
# While used as a filter, the filenames are normalized, matched
# against some filters and, depending on the result, written to
# 1.txt (new), 2.txt or 3.txt (different blocklists) as long as
# they are neither in f_getlist or f_blocklist.
#
# to download, move a line from 1.txt to f_getlist.
# to never display a line again, move it to f_blocklist.
# (if the filter is still active, rename the .txt-file first).
#

($cwd=$0)=~s/\/[^\/]*$//;
chdir $cwd;

#begin program variables
$GETLIST="f_getlist";
$BLOCKLIST="f_blocklist";
$NAPDIR="/d/napshare/"; #don't omit the slash!
#end program variables
#begin system variables
$FGREP="/usr/bin/fgrep";
#end system variables

$blocklist_f = "remix|.(wma|asf)\$|\\bentire album\\b";
$block_f="^t - [0-9]{7}|\^read ?me";
$blocklist_a = "\\b(Backstreet Boys|Janet Jackson|Missy Elliott)\\b";

$genres="\\&|[6-9]0s( music)?|alternative|copy (\([0-9]+\) )?of|new wave|oldies

$mode=' ';
$instring = $ARGV[0];
if(($instring=~s/^-(.)$/$1/)==1){
$mode=$instring;
$instring = $ARGV[1];
}

($ofilename, $size, $speed, $status, $tag) = split(/\//,$instring,5);

check: while(1) {
if($ofilename =~ /$block_f/i) {
$status=3;
last check;
}
($filename=$ofilename) =~ s/_|%20|\~/ /g;
$filename =~ s/\'| $//g;
$filename =~ s/-/ - /g;
$filename =~ s/ +/ /g;
$filename =~ s/(- )+/- /g;
do { $filename =~ s/^ -? ?//g;
} until(($filename =~ s/^($genres|\(($genres)\)|\[$genres\]|\{$genres\}
$filename =~ s/^ -? ?//g;
if(($filename =~ s/^\(([A-Za-z0-9, ]*)\)/$1 - /)
|| ($filename =~ s/^\(([A-Za-z0-9, ]*)\)/$1 - /)){
$filename =~ s/ +/ /g;
$filename =~ s/(- )+/- /g;
$filename =~ s/^ -? ?//g;
}

if(!system $FGREP, '-qsxi', '--', $filename, $GETLIST) {
$status=0;
} elsif(!system $FGREP, '-qsxi', '--', $filename, $BLOCKLIST){
$status=18;
} else {
$status=1;
##################################
if ($filename =~ /\.mp3$/i) {
($f=$filename) =~ s/(\.mp3)*$//i;
if ($f=~ /$blocklist_f/i) {
$status=2;
last check;
} elsif(-e $NAPDIR.$filename) {
$status=0;
last check;
}
@test = split(/ - /, $f, -1);
for($i=0;$i<@test;$i++){
if($test[$i] eq ""){splice(@test,$i,1);}
}
if(@test==1) {
@test = split(/[\(\)]/, $f, -1);
for($i=0;$i<@test;$i++){
if($test[$i] eq ""){splice(@test,$i,1);}
} }
if ($test[0] =~ /$blocklist_a/i) {
$status=2;
last check;
}

print @test.'#' .join(':', @test) . "\n";

# $status=0;
last check;
##################################
}
last check;
}
last check;
}

if($status == 0) { exit 0;}
if($status<16){
$LogFile = $status.".txt";
((-e $LogFile)? open(LOG,">>$LogFile"):open(LOG,">$LogFile"))
|| die("Can't open $LogFile: $!\n");
print LOG $filename."\n";
} else { print $status-16 .$filename."\n"; }

exit $status!=0;
Back to top View user's profile Send private message
KipFrabrisp
-


Joined: 31 Dec 2009
Posts: 1
Location: Guam

PostPosted: Sat Jan 02, 2010 12:19 am    Post subject: Upload script failure Reply with quote

Do you understand what youre doing?
mod_rewrite Rewrite engine has nothing to do with changing php settings.

in .htaccess
Code:php_value upload_max_filesize 40Mphp_value post_max_size 10Mphp_flag is for on / off setting.
for other setting, use php_value instead.
Back to top View user's profile Send private message Send e-mail ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group