Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 16 to 27 of 27
  1. #16
    Member
    Join Date
    Sep 2004
    Location
    inside a catfish
    Posts
    963
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by mjurmann View Post
    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)
    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.

    Quote Originally Posted by mjurmann View Post
    How do I go about telling an application to use a different temp directory other than the default tmp/ ?
    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

  2. #17
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    Alright, thanks anyways.

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

  3. #18
    Member
    Join Date
    Sep 2004
    Location
    inside a catfish
    Posts
    963
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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
    Last edited by mtindor; 09-25-2007 at 10:25 PM.

  4. #19
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    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)

  5. #20
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    Someone help me please. I've been sitting here for 15 hours straight.

  6. #21
    Member serversphere's Avatar
    Join Date
    Jan 2004
    Posts
    658

    Default

    Change your tmp back in php.ini - that is server wide setting. You don't want other accounts writing to your /tmp (in fact they probably cant and will get errors).

    Now, is this a CMS or something you are writing yourself? You should always move your files to a directory in that you KNOW you have write/execute permissions before doing anything with them:

    Code:
    $uploadDir = "/home/your_account_dir/uploads/";  // or something similar
    $uploadedfile = $uploadDir . basename($_FILES["uploaded2"]["tmp_name"]);
    
    if (move_uploaded_file($_FILES["uploaded2"]["tmp_name"], $uploadedfile)) {
        echo "File is valid, and was successfully uploaded.\n";
    } else {
        echo "File not saved!\n";
    }
    Now the file is in your upload directory, one that is not in a location mounted as noexec, so you should be able to work with it.

    PS: I should say this as well - make sure you create the directory "uploads" in your account directory and that it has the correct permissions before you run this or you will get an error with this as well..

    Code:
    $src = imagecreatefromjpeg($uploadedfile);
    var_dump($src);
    If you still get errors there could be something else wrong. The question then becomes, is it actually uploading the file at all? Can you see it in /tmp post upload? etc... but first let's try moving it and see how that goes.
    Last edited by serversphere; 09-26-2007 at 08:50 AM.
    Darren Benfer | SS-Darren | AIM: serversphere
    www.serversphere.com
    Dedicated Server Solutions Have Come Full Circle

  7. #22
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    I made the necessary changes you illustrated. I changed the temp directory back to the default, global tmp directory. I created an upload folder at /home/myUsername/public_html/tmp. I chmoded 777 the directory.

    I first tested to make sure the directory was writable by having a file uploaded from the same POST method that I'm trying to use for this image resize function (except this method I'm just uploading the file and saving it as is, no alterations, no temporary files). It saved fine.

    Then when I added:

    $uploadDir = "/home/gameargu/public_html/tmp/"; // or something similar

    to my resize script, it came back with this error:

    File not saved!
    Warning: imagecreatefromjpeg(/home/gameargu/public_html/tmp/phpxIqKxn) [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 313


    It still telling me that it wasn't saved! Wow, I just don't understand. :/

  8. #23
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    I also must mention that the file being uploaded using POST is being uploaded from the previous page - I know this because I also have this script on the page:

    Code:
      <?php
    $target = "box_images/";
    $target = $target .$pictureNum."_banner_". basename( $_FILES['uploaded2']['name']) ;
    $ok=1;
    
    
    
    
    if ($uploaded_size > 350000)
    {
    echo "Your file is too large.<br>";
    $ok=0;
    }
    
    
    
    
    if ($ok==0)
    {
    Echo "Sorry your file was not uploaded";
    } 
    
    
    else
    { 
    
    
    if(move_uploaded_file($_FILES['uploaded2']['tmp_name'], $target))
    {
    chmod($target, 0777);
    
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    
    
    }
    
    
    
    ?>
    As I mentioned in the last post, this is just a script to save the image in its native size to the server. There is no resizing or need for a temporary file, so I think that is why this is uploading and working correctly.

    However, the resized thumbnail of this same file is the one that is giving me problems.

  9. #24
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    Alright, so it works - kinda.

    I had to move the scripts around. I think the first way I had it:

    Code:
    				
    						  <?php
    $target = "box_images/";
    $target = $target .$pictureNum."_box_". basename( $_FILES['uploaded']['name']) ;
    $ok=1;
    
    
    
    
    if ($uploaded_size > 350000)
    {
    echo "Your file is too large.<br>";
    $ok=0;
    }
    
    
    
    
    if ($ok==0)
    {
    Echo "Sorry your file was not uploaded";
    } 
    
    
    else
    { 
    
    
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
    chmod($target, 0777);
    
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    
    
    }
    
    
    ?>
    
    	  <?php
    $target = "box_images/";
    $target = $target .$pictureNum."_banner_". basename( $_FILES['uploaded2']['name']) ;
    $ok=1;
    
    
    
    
    if ($uploaded_size > 350000)
    {
    echo "Your file is too large.<br>";
    $ok=0;
    }
    
    
    
    
    if ($ok==0)
    {
    Echo "Sorry your file was not uploaded";
    } 
    
    
    else
    { 
    
    
    if(move_uploaded_file($_FILES['uploaded2']['tmp_name'], $target))
    {
    chmod($target, 0777);
    
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    
    
    }
    
    
    
    ?>
    
    
    
    
    <?php if ($_FILES['uploaded2']['tmp_name'] == NULL) {
    
    }
    
    else {
    error_reporting(E_ALL);
    
    $uploadDir = "/home/gameargu/public_html/tmp/";  // or something similar
    $uploadedfile = $uploadDir . basename($_FILES["uploaded2"]["tmp_name"]);
    
    if (move_uploaded_file($_FILES["uploaded2"]["tmp_name"], $uploadedfile)) {
        echo "File is valid, and was successfully uploaded.\n";
    } else {
        echo "File not saved!\n";
    }
    
    // Create an Image from it so we can do the resize
    $src = imagecreatefromjpeg($uploadedfile);
    
    // Capture the original size of the uploaded image
    list($width,$height)=getimagesize($uploadedfile);
    
    // For our purposes, I have resized the image to be
    // 600 pixels wide, and maintain the original aspect
    // ratio. This prevents the image from being "stretched"
    // or "squashed". If you prefer some max width other than
    // 600, simply change the $newwidth variable
    $newwidth=150;
    $newheight=($height/$width)*150;
    $tmp=imagecreatetruecolor($newwidth,$newheight);
    
    
    
    // this line actually does the image resizing, copying from the original
    // image into the $tmp image
    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
    
    // now write the resized image to disk. I have assumed that you want the
    // resized, uploaded image file to reside in the ./images subdirectory.
    $filename = "games_images/thumbs/".$pictureNum."_".$_FILES['uploaded2']['name'];
    imagejpeg($tmp,$filename,100);
    
    echo $filename;
    
    imagedestroy($src);
    imagedestroy($tmp);
    
    // NOTE: PHP will clean up the temp file it created when the request
    // has completed.
    }
    ?>
    It was taking the file and moving it before it actually got to the image resizing script (the last script in that code).

    I changed it to:

    Code:
    <?php if ($_FILES['uploaded2']['tmp_name'] == NULL) {
    
    }
    
    else {
    error_reporting(E_ALL);
    
    $uploadDir = "/home/gameargu/public_html/cms/htms/tmp_imgs/";  // or something similar
    $uploadedfile = $uploadDir . basename($_FILES["uploaded2"]["tmp_name"]);
    
    if (move_uploaded_file($_FILES["uploaded2"]["tmp_name"], $uploadedfile)) {
        echo "File is valid, and was successfully uploaded.\n";
    } else {
        echo "File not saved!\n";
    }
    
    // Create an Image from it so we can do the resize
    $src = imagecreatefromjpeg($uploadedfile);
    
    // Capture the original size of the uploaded image
    list($width,$height)=getimagesize($uploadedfile);
    
    // For our purposes, I have resized the image to be
    // 600 pixels wide, and maintain the original aspect
    // ratio. This prevents the image from being "stretched"
    // or "squashed". If you prefer some max width other than
    // 600, simply change the $newwidth variable
    $newwidth=150;
    $newheight=($height/$width)*150;
    $tmp=imagecreatetruecolor($newwidth,$newheight);
    
    
    
    // this line actually does the image resizing, copying from the original
    // image into the $tmp image
    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
    
    // now write the resized image to disk. I have assumed that you want the
    // resized, uploaded image file to reside in the ./images subdirectory.
    $filename = "games_images/thumbs/".$pictureNum."_".$_FILES['uploaded2']['name'];
    imagejpeg($tmp,$filename,100);
    
    echo $filename;
    
    imagedestroy($src);
    imagedestroy($tmp);
    
    // NOTE: PHP will clean up the temp file it created when the request
    // has completed.
    }
    ?>
    						
    					
    						  <?php
    $target = "box_images/";
    $target = $target .$pictureNum."_box_". basename( $_FILES['uploaded']['name']) ;
    $ok=1;
    
    
    
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
    chmod($target, 0777);
    
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    
    ?>
    
    	  <?php
    $target = "box_images/";
    $target = $target .$pictureNum."_banner_". basename( $_FILES['uploaded2']['name']) ;
    $ok=1;
    
    
    
    if(move_uploaded_file($_FILES['uploaded2']['tmp_name'], $target))
    {
    chmod($target, 0777);
    
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    
    
    ?>
    and it seems that the resizer works now. However, my native size image is not working now. Is there a way I could code this so I could have the image resized and also same as a native form with the code that I have above?

  10. #25
    Member serversphere's Avatar
    Join Date
    Jan 2004
    Posts
    658

    Default

    I don't think you can move the native image more than once, though I could be wrong. I don't understand why you aren't moving it to your box_images directory right away? Then you wouldn't have to move it again.
    Darren Benfer | SS-Darren | AIM: serversphere
    www.serversphere.com
    Dedicated Server Solutions Have Come Full Circle

  11. #26
    Member
    Join Date
    Sep 2007
    Posts
    15

    Default

    Don't worry about it - I'm going to not use that now.

    However, you did solve my problem and help my not go insane, so thank you.

    Thank you very much. You're smarter than any of the baboons working at my ISP.

  12. #27
    Member serversphere's Avatar
    Join Date
    Jan 2004
    Posts
    658

    Default

    LOL. Sure thing. If you need more PHP help in the future might I recommend an excellent forum : codingforums.com. They have a php section there with some extremely helpful folks.
    Darren Benfer | SS-Darren | AIM: serversphere
    www.serversphere.com
    Dedicated Server Solutions Have Come Full Circle

Similar Threads & Tags
Similar threads

  1. Fatal error: Call to undefined function imagecreatefromjpeg()
    By rustikat in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-05-2007, 03:55 PM
  2. Cpanel/WHM problem, Exim problem, Mail problem
    By iroku in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 08-18-2006, 04:28 PM
  3. Email Sending Problem (451 Temporary local problem)
    By saj in forum E-mail Discussions
    Replies: 1
    Last Post: 03-30-2006, 10:07 AM
  4. Weird problem, urgent help needed with Mail problem
    By fuzioneer in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-07-2005, 04:00 AM
  5. FDF problem : Today I have problem when upgrade Apache
    By xmllist in forum cPanel Developers
    Replies: 0
    Last Post: 06-18-2004, 11:26 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube