SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GetImageSize giving me headaches.

    Basically, what I'm trying to do is upload an image and get the size of it when I'm done. I keep getting the following error:

    http://www.sohh.com/images/covers/al...lifestyles.jpg
    Warning: Unable to open http://www.sohh.com/images/covers/al...lifestyles.jpg in /usr/local/www/docs/sohh.com/pub2000/image_library_upload_step2.php on line 92

    But if you go to: http://www.sohh.com/images/covers/al...lifestyles.jpg you'll notice the image is there.

    On line 92 I have:

    $imagehw = GetImageSize($pathrelative);

    This is the entire code:

    // SET MAX FILESIZE (50k)

    $max_filesize = 50 * 1000;

    // COMBINE THE FILENAME WITH THE PROPER DIRECTORY

    // CREATE THE PATH TO WHERE THE FILE WILL BE SAVED
    $pathnormal = "images/covers/album/" . basename($userfile_name);

    // CREATE THE ABSOLUTE PATH TO WHERE THE FILE WILL BE SAVED
    $pathsave = "/usr/local/www/docs/sohh.com/" . $pathnormal;

    // CREATE THE RELATIVE PATH TO WHERE THE FILE WILL BE SAVED
    $pathrelative = "http://www.sohh.com/" . $pathnormal;

    if ($userfile_size > $max_filesize) {

    $message = "Sorry the file you are trying to upload is over 50k";

    echo $message;

    exit;

    } else if (!copy($userfile, $pathsave)) {

    $message = "Sorry the file you are trying to upload already exists";

    echo $message;

    exit;

    } else {

    $message = "file successfully uploaded";

    }

    $imagehw = GetImageSize($pathrelative);

    $imagewidth = $imagehw[0];

    $imageheight = $imagehw[1];

    $previewimage = $relativeimage;

    Any help is appreciated.
    <///////~

    www.sohh.com

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is you need to get the image size from the absolute path not the http path so chage

    $imagehw = GetImageSize($pathrelative);

    to

    $imagehw = GetImageSize($pathsave);
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    Non-Member MrLister's Avatar
    Join Date
    Feb 2001
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in scripts. how do you know when you're suppose to use which.

    http://somehting.com
    or
    /www/usr/blah

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For something like GetImageSize() you need system paths, I know it says you can use web addresses at php.net but I have never been able to get it to work using that method.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was going by what PHP.net said myself. Sometimes that site is not so helpful. I've found better tips on this site than there - most of the time.

    Anyway, is there a way to use GetImageSize() on an image not on your server. I was trying that as well but no luck. Maybe I'm doing something wrong.

    one
    <///////~

    www.sohh.com

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Keep this in mind. From http://www.php.net/manual/en/function.getimagesize.php :

    Note: URL support was added in PHP 4.0.5
    If you want to get an image that's not on your server, you can use fopen() + fread() to grab the image. You can then write it to a temporary file on your server and read it like that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •