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!

Uploading problem

Status
Not open for further replies.

ETbyrne

Programmer
Dec 27, 2006
59
US
Hi, I'm having a problem uploading a file using perl. I can get the file uploaded but it becomes distorted. Here's the uploading part of the script.

Code:
open(OUT,">./mywebs/ETbyrne/youth/album/images/$random.jpg") or &error("Can not open outfile for writing: $!");
flock(OUT,LOCK_EX);
my $file_len = 0;
while (read($file,my $i,1024))
  {
  print OUT $i;
  $file_len = $file_len + 1024;
  if ($file_len > 1024000)
    {
    close(OUT);
    &error("File is to large, photo must be less than 1MB. Save aborted.");
    }
  }
close(OUT);

Thanks for all help!

_______________________________________

You don't know me.
 
Not sure what a "distorted" file means, but you probably just need to use binmode:

Code:
open(OUT,">./mywebs/ETbyrne/youth/album/images/$random.jpg") or &error("Can not open outfile for writing: $!");
[b]binmode(OUT);[/b]

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks, that was what I needed!

And by distorted I meant that it uploaded the file and it was the right hight and width, but the image was screwed up, like three times as bad as if you saved a .bmp with tons of detail as a .gif. x_x

_______________________________________

You don't know me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top