Forum Moderators: coopster & phranque

Message Too Old, No Replies

Upload Large File Problem

using perl

         

jackljack

3:18 am on May 6, 2003 (gmt 0)

10+ Year Member




$fileName = $f[$i];
$fileName =~ s!^.*(\\¦\/)!; # Remove path
$buff = 0;
if ($f[$i] ne "") {
open (THEFILE, ">$fileName");
while (read($f[$i], $buff, 32768)) {
print THEFILE $buff;
}
close (THEFILE);
}

jackljack

3:19 am on May 6, 2003 (gmt 0)

10+ Year Member



Oops...forgot the ask the question.

The posted script works fine with files smaller than 3MB. What do I have to do to make it work with larger files? Thanks!

jatar_k

3:23 am on May 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld jackljack,

maybe a little more info would help. How big are the files you are trying to upload? Have you checked the upload_max_filesize setting?

maybe this will help
Handling file uploads [php.net]

jackljack

3:28 am on May 6, 2003 (gmt 0)

10+ Year Member



The file I'm trying to upload is 6MB. I had no problem with a 3MB file. I don't know anything about "upload_max_filesize"..is is on the web server?

Here's the entire code...Thanks!

#################### upload_now
sub upload_now {
$path = "upload\/";
$message = "Someone uploaded something to the server:\r\n\r\n";
print "Content-type: text/html\n\n";
$f[1] = $query->param("fn1");
$f[2] = $query->param("fn2");
$f[3] = $query->param("fn3");
$f[4] = $query->param("fn4");
$f[5] = $query->param("fn5");
for ($i = 1; $i <= 5; $i++) {
$fileName = $f[$i];
$fileName =~ s!^.*(\\¦\/)!; # Remove path
$buff = 0;
if ($f[$i] ne "") {
$message = $message."http\:\/\/www\.wow\.com\/upload\/$fileName\r\n";
open (THEFILE, ">$path$fileName");
while (read($f[$i], $buff, 32768)) {
print THEFILE $buff;
}
close (THEFILE);
}
}
$to = $admin;
$from = $admin;
$subject = "Job Upload";
&smail;
&flash ("Uploaded.", $home);
}

jatar_k

3:32 am on May 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



upload_max_filesize [php.net] is et in the php.ini. Try using phpinfo [php.net] to check the setting

jackljack

3:33 am on May 6, 2003 (gmt 0)

10+ Year Member



Sorry...I didn't specify, this is Perl CGI...not PHP.

jatar_k

3:36 am on May 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



sorry, first post looked like php-esque, the second bit of code looks like perl but didnt really look that closely, sorry

jackljack

3:44 am on May 6, 2003 (gmt 0)

10+ Year Member



Do you have any idea why it's not working?

jatar_k

3:45 am on May 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what about read? is that set high enough? Not sure how it works in perl.

andreasfriedrich

6:27 pm on May 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




>>=~

Not exactly PHP [php.net]-esque, is it Adam? Think preg_* in PHP [php.net].

Since you seem to be using the CGI [perldoc.com] module anyway ($query->param("fn3");), why not use its file upload feature [perldoc.com] as well?

>>what about read? is that set high enough?

Since it is called within a loop the entire file will be read from STDIN no matter what buffer size you use for read [perldoc.com].

If you are using the CGI [perldoc.com] module indeed check $CGI::POST_MAX.

Andreas

jatar_k

10:12 pm on May 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



=~
Not exactly PHP-esque, is it Adam?

yep, missed that, funny guy ;)