mjurmann

Member
Sep 25, 2007
15
0
51
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...
 

bin_asc

Well-Known Member
Jul 18, 2005
280
0
166
Seems like you have permission issues to the /tmp/. Check that you can read/write to /tmp.
 

mjurmann

Member
Sep 25, 2007
15
0
51
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?
 

bin_asc

Well-Known Member
Jul 18, 2005
280
0
166
In the root. The /tmp/ partition. When you ssh in, type ls, you should see the /tmp
 

mjurmann

Member
Sep 25, 2007
15
0
51
Is there a way to see what the default permissions are for that directory in SSH? A command?
 

mjurmann

Member
Sep 25, 2007
15
0
51
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
 

bin_asc

Well-Known Member
Jul 18, 2005
280
0
166
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 ;)
 

mtindor

Well-Known Member
Sep 14, 2004
1,394
72
178
inside a catfish
cPanel Access Level
Root Administrator
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
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
 

mjurmann

Member
Sep 25, 2007
15
0
51
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.
 

mjurmann

Member
Sep 25, 2007
15
0
51
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
 

mctDarren

Well-Known Member
Jan 6, 2004
662
6
168
New Jersey
cPanel Access Level
Root Administrator
I'm also guessing you don't have /tmp mounted noexec, probably aren't running phpsuexec or suexec
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.
 

mjurmann

Member
Sep 25, 2007
15
0
51
"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?
 

mtindor

Well-Known Member
Sep 14, 2004
1,394
72
178
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
 

mjurmann

Member
Sep 25, 2007
15
0
51
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/ ?
 

mtindor

Well-Known Member
Sep 14, 2004
1,394
72
178
inside a catfish
cPanel Access Level
Root Administrator
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.

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
 

mtindor

Well-Known Member
Sep 14, 2004
1,394
72
178
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
 
Last edited:

mjurmann

Member
Sep 25, 2007
15
0
51
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)