CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
Rather urgent help needed...



Oct 5, 2000, 11:37 AM

Post #1 of 3 (1733 views)
Rather urgent help needed... Can't Post

Sorry for asking again but time is not a luxury for me at this stage of the project... So, I've got this file upload routine that won't start. I get no error messages, just a 0 byte length file at the end (on the server). The filename on the server is right. The code (I "borrowed" from here and there so it's not all by me...) :

use CGI;
use IO::Handle;
use IO::File;
use CGI::Carp 'fatalsToBrowser';
$objetcgi = new CGI;

$file = $objetcgi->param("image");
$nomimage = $objetcgi->param("nomimage");

$fh = new IO::Handle->fdopen(fileno($file), "r");
$newfh = new IO::File $nomimage, "w";
if ($^O =~ /Win32/) {
while ($bytesread = sysread($fh, $buffer, 1024)) {
$kb += ($bytesread / 1000);
$n = syswrite($newfh, $buffer, $bytesread);
close ($newfh);
close ($fh);

So, $nomimage is the new filename and seems ok. The $file is the upload field from the form. I am using a multipart as form field. Running, the script, I've seen it doesn't even go through the while loop and just opens and closes both read and write filehandles. If someone could please help on this, I'd be eternally grateful (I often am to a lot of people these days!) Wink Thanks in advance!

p.s.: I tried another version of script (the one from Anthony et al. a couple of posts back) and got the exact same results as with the above mentionned script. Frown

[This message has been edited by Merlin (edited 10-05-2000).]


Oct 8, 2000, 8:03 PM

Post #2 of 3 (1733 views)
Re: Rather urgent help needed... [In reply to] Can't Post

I don't see anything obviously wrong, other than that you're not checking for errors on your file opens. It's worth noting that sysread() and syswrite() bypass buffering. Unless you know the actual blocksize for the disk, you're better off using print and letting Perl manage the I/O buffering for you. (The blocksize is not very likely to be 1024 bytes. 8K is a more common number.)


Oct 10, 2000, 1:47 PM

Post #3 of 3 (1733 views)
Re: Rather urgent help needed... [In reply to] Can't Post

Thanks for the info. I tried some other stuff with this and... well, check the other post I'm going to post right now about being almost there... Thanks again!


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives