in reply to Re^2: FIle Upload Error Help!
in thread FIle Upload Error Help!

I've no idea what is in $img, other than it's a string. Perhaps all you want is:
$url = new URI::URL($urls); $req = new HTTP::Request('GET', $url, $hdrs); $ua = new LWP::UserAgent; $resp = $ua->request($req); if ($resp->is_success) { open(IMAGE, ">../../img/$filename") or die "$!"; binmode IMAGE; print IMAGE $resp->content; }
But then you may want to use LWP::Simple instead.

Replies are listed 'Best First'.
Re^4: FIle Upload Error Help!
by Anonymous Monk on Jul 21, 2011 at 19:34 UTC
    That I know works, I tried as well but I would like to read this image file before using the code inside of the while loop. Just in case the image been uplaoded is too big. The $img has the image itself from the urls.
      So, you're assuming that read is some magical function which you can feed a URL? Where did you get that idea from? And if you think that you can feed read a URL, why didn't you try to read to fetch the document containing the URL to the image?

      I'd use LWP::Simple and its getprint method. That will take a URL, and write it to the selected filehandle. Which is what you want.

      I would like to read this image file before using the code inside of the while loop. Just in case the image been uplaoded is too big

      Not a good way of finding out the file size, the simplest is to use -s. For example:
      my $size = -s IMAGE;
      or :
      my $size = -s $filename;