The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with imagecreatefromjpeg();

Discussion in 'General Discussion' started by mjurmann, Sep 25, 2007.

  1. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Hi guys, I'm having a real tough time here.


    I've recompiled Apache with the gdlib in WHM; however, when I attempt to run:

    Code:
    error_reporting(E_ALL);
    
    // This is the temporary file created by PHP
    $uploadedfile = $_FILES['uploaded2']['tmp_name'];
    
    echo $uploadedfile;
    echo "<br/>";
    echo "<br/>";
    
    // Create an Image from it so we can do the resize
    
    $src = imagecreatefromjpeg($uploadedfile);
    var_dump($src);
    I get this:

    Warning: imagecreatefromjpeg(/tmp/phpk8YWjD) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/gameargu/public_html/cms/htms/admin-games-image-uploaded.php on line 312
    bool(false)

    I can't figure out why my temporary images are not saving on the server. Is there a setting I need to change in WHM? Please help...
     
  2. bin_asc

    bin_asc Well-Known Member

    Joined:
    Jul 18, 2005
    Messages:
    280
    Likes Received:
    0
    Trophy Points:
    16
    Seems like you have permission issues to the /tmp/. Check that you can read/write to /tmp.
     
  3. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Bin, first of all, thank you for helping me.

    Second, is the /tmp/ it is referring to the /tmp/ in my root, or is it the /tmp/ in the directory relative to where my script is?
     
  4. bin_asc

    bin_asc Well-Known Member

    Joined:
    Jul 18, 2005
    Messages:
    280
    Likes Received:
    0
    Trophy Points:
    16
    In the root. The /tmp/ partition. When you ssh in, type ls, you should see the /tmp
     
  5. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Is there a way to see what the default permissions are for that directory in SSH? A command?
     
  6. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,281
    Likes Received:
    37
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator

    ls -alt /|grep tmp
     
  7. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I chmoded tmp in the root to 777 and then ran ls -l. The result was: drwxrwxrwx

    It's still not working...that is why I'm not sure if the command imagecreatefromjpeg is pointing to the right /tmp/ dir
     
  8. bin_asc

    bin_asc Well-Known Member

    Joined:
    Jul 18, 2005
    Messages:
    280
    Likes Received:
    0
    Trophy Points:
    16
    It is. I can take a look tomorrow at it, if you`d like, now I`m heading for zZzZz ... late here, good luck either way ;)
     
  9. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,281
    Likes Received:
    37
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    First thing you'll want to do is chmod /tmp back to what it was before you changed it to 777. chmod'ing 777 is not the answer.

    Randomly chmoding directories (especially /tmp) to 777 puts you well on your way to getting rooted - because I'm also guessing you don't have /tmp mounted noexec, probably aren't running phpsuexec or suexec, and probably aren't running mod_security.

    Mike
     
  10. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Alright Mike, I chmoded it back to what it was.

    Do you have any idea why I'm getting this error? This function worked fine on the 3 shared servers I was on before this dedicated server that I'm using.
     
  11. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    This is so confusing to me because according to phpinfo():


    Configure command:

    --with-gd' '--with-jpeg-dir=/usr/local'

    gd
    GD Support enabled
    GD Version bundled (2.0.28 compatible)
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled
    XBM Support enabled

    Everything looks enabled and I just can't figure out why it won't put the file in the tmp directory
     
  12. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    I'm guessing this is the very problem. Try moving the file to your the account's directory first and then creating from it. You might not be able to execute in tmp because of one of the above.
     
  13. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    "Try moving the file to your the account's directory first and then creating from it. You might not be able to execute in tmp because of one of the above."

    Could you please explain this to me a little better? What file do I need to move to what directoy?
     
  14. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,281
    Likes Received:
    37
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    I think he is saying that you should get your application to use /home/your_account_name/tmp as the temp directory instead of it using the default /tmp - because of the way permissions may be set on /tmp.

    Also - Via SSH:

    ls -alt / |grep tmp
    - show the results to us

    mount |grep tmp
    - show the results to us

    This way we can see what perms are on your /tmp directory and what mount directives were used.

    Mike
     
  15. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    ls -alt / |grep tmp

    drwxrwxrwx 7 gameargu gameargu 4096 Sep 25 16:38 tmp

    mount |grep tmp

    none on /dev/shm type tmpfs (rw)
    /dev/sda7 on /tmp type ext3 (rw,noexec,nosuid)
    /tmp on /var/tmp type none (rw,noexec,nosuid,bind)

    How do I go about telling an application to use a different temp directory other than the default tmp/ ?
     
  16. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,281
    Likes Received:
    37
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    Ok that's good (really, it is, even if your script is not working). This means that when the system was upgraded /scripts/securetmp was run. But that doesn't solve your problem - It just lets us know more of what is happening.

    I don't know the answer to that question - I'm not a PHP guru :( Hopefully somebody else will provide you with an adequate answer.

    Mike
     
  17. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Alright, thanks anyways.

    Does anyone else have any clue why this isn't working?
     
  18. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,281
    Likes Received:
    37
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    Also, - in the CMS that you are running, check to see if there is a place to specify an upload directory. If there is, specify an upload directory that is within your basedir (such as a directory in /home/accountname or /home/accountname/tmp or some other directory in /home/accountname that you create which has appropriate permissions for the upload to work. If your server is not running phpsuexec, you'll probably need that directory that you create to be chmod 777 - But 755 should be fine if your server is running phpsuexec.

    Somewhere in your CMS you might be able to specify the upload directory. I don't know. And I don't know if the upload directory is merely the 'final' resting spot of the uploaded file and if php is going to 'temporarily' upload it to /tmp regardless.

    Oh - and if those graphics that are uploaded are supposed to be viewable via the web directly afterwards, the directory would probably need to be /home/accountname/public_html/something . Again, I know not enough about your configuration to assist you any further.

    Mike
     
    #18 mtindor, Sep 25, 2007
    Last edited: Sep 25, 2007
  19. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Ok, I changed the temp upload directory in php.ini:to /home/gameargu/public_html/tmp/

    This is where is says the temp file is located at:

    /home/gameargu/public_html/tmp/phpIykMLX

    But I'm still getting this. Why!! Ahhh!!!

    Warning: imagecreatefromjpeg(/home/gameargu/public_html/tmp/phpIykMLX) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/gameargu/public_html/cms/htms/admin-games-image-uploaded.php on line 312
    bool(false)
     
  20. mjurmann

    mjurmann Member

    Joined:
    Sep 25, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Someone help me please. I've been sitting here for 15 hours straight.
     
Loading...

Share This Page