HCSuperStores Posted February 26, 2004 Posted February 26, 2004 Hi Guys, I've spent hours on this, checked and rechecked. I hate asking for script help ... I feel like I failed. The script I have has worked on another host, but I had issues with uploading a file with TCH from the start. Not sure why. I tried revamping it some, but it's just so darn simple it should work. Anyway here is the script. It's a subroutine that receives a file name from a form: #!/usr/bin/perl sub subgetimagefile { ##### Read in the image file ##### my ($imagefile) = @_; print "Image filepath length: ".length($imagefile)."<br>"; print "Image File: $imagefile<br>"; my $size=0; my $data; while (my $bytesread = read($data, my $buffer, 1024) or die("Error uploading file: $!\n")) { print "Reading: $size<br>"; $size+=$bytesread; $content.=$buffer; print "Read: $size<br>"; } return $content; } return 1; *************** Here is what I get when I try to use it after selecting a file. *************** Image filepath length: 44 Image File: C:\WINDOWS\Desktop\Ian Parker Hermonat 2.jpg Content-type: text/html Software error: Error uploading file: Bad file descriptor Anybody else get these types of errors? Please help. Thank you, Bill Quote
TCH-Bruce Posted February 26, 2004 Posted February 26, 2004 Bill from the error it looks like it's not taking into account the MIME type for a .jpg. I had a script I used to use that used binmode to upload. while ($bytesread = read($filename,$buffer,1024)) { $totalbytes += $bytesread; binmode OUTFILE; print OUTFILE $buffer; This scipt required the CGI.pm module. Quote
HCSuperStores Posted February 26, 2004 Author Posted February 26, 2004 Hi Bruce, Thanks for the suggestion, but from what I can tell I don't think that's it. It's like it's having a problem opening the file or getting to it. It never outputs the first "print" to show that it is reading the file. It's just weird. Like it's having trouble making the connection. Maybe I'm just stuck in the way I'm looking at it. But even if I comment out anything with what it does with the file it still gives the error. It just won't read the file. Yuck! Any other suggestions are welcome! Bill Quote
HCSuperStores Posted February 26, 2004 Author Posted February 26, 2004 Aparently I've found my answer. I tried to break the file load routine up and have it be a subprogram. However, this just didn't work. The perl code, for a lack of a better explanation, just seemed sensitive. I would work inside, in-line, but when made a subprogram, it bombed out with the error. I've got it working now. Thanks for trying! Bill Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.