Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Upload 2

Status
Not open for further replies.

skosterow

Technical User
Feb 23, 2002
135
US
Okay I think I'm a dorkis - but here goes - I have been searching for a way to upload Binnary stuff IE gifs and jpegs to my server via perl - here is the code that im using:

use CGI;
$upload_dir = "/uploads";

$query = new CGI;

$filename = $query->param('upload_file');
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("upload_file");

open UPLOADFILE, ">$upload_dir/$filename";

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}

close UPLOADFILE;

print $query->header ( );

however, the image comes out bad i mean really bad - how can i tell perl to upload in binnary mode using the above?

thanks in advance!

- Scott

Wise men ask questions, only fools keep quite.
 
put this before the while statement:-

binmode UPLOADFILE;

... and see how you get on


Kind Regards
Duncan
 
Thank you duncdude!

That was it!!!!!!

One question - when i want to do txt files then i use the first way and thats that right?

- Scott

Wise men ask questions, only fools keep quite.
 
Its not bad using binmode all the time you know.

It doesn't keep you up at nights. :)
 
perluserpengo - kewl beans thanks guys!

- Scott

Wise men ask questions, only fools keep quite.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top