By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,115 Members | 828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,115 IT Pros & Developers. It's quick & easy.

Configuring PHP with GD support

P: 44
Hi to all,

Firstly I must state my knowledge of php is limited but I am a quick learner. I have taken on the task of finishing a friends website due to his untimely passing and have hit a problem with the completion of his work.

The site involves the uploading of a picture, jpg, png or gif. as part of an order process. The files involved are called order.php, step1.php and then step2.php.

The picture uploads to the upload folder, (called uploads), ok and step1.php is called/initiated but then fails to move to step 2. Once the picture is uploaded it is supposed to have a thumbnail produced which is to be stored in a serperate folder, called thumbs, and this is used in step2.php. The thumbnail is not being created and step2 is not called.

Some info that may be useful, is that the site has just been moved to a dedicated server. I'm not sure if this would make any difference.

It is a linux based server but then the old one was too.

The upload folders have full permissions

I have added the

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', True);
  5. ?> 
  6.  
  7.  
to the step1.php file and this reported the following error.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Fatal error: Call to undefined function imagecreatefromjpeg() 
  3.  
  4.  
If the file is a gif or png then the error differs in relation to the upload file type.
Here is the section of code where this line reports to.

Expand|Select|Wrap|Line Numbers
  1.  
  2. if ( (strtolower($ext)=="jpg") || (strtolower($ext)=="jpeg") ) {
  3.     $imgOriginal = imagecreatefromjpeg($storePath);
  4.  
  5. } elseif (strtolower($ext)=="gif") {
  6.     $imgOriginal = imagecreatefromgif($storePath);
  7.  
  8. } elseif (strtolower($ext)=="png") {
  9.     $imgOriginal = imagecreatefrompng($storePath);
  10.  
  11. } else {
  12.     debug("Uploaded file didn't appear to be a web safe image.");
  13.  
  14. ob_end_flush();
  15. exit(0);
  16. }
  17.  
  18.  
I am not sure if this is enough information so I will add the entire step1.php for assistance.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', True);
  5. ?> 
  6.  
  7.  
  8. <?php
  9. session_start();
  10. ob_start();
  11.  
  12. // javascript was required so the user will never use the degraded version
  13. $used_degraded = false;
  14.  
  15. // my debug function. comment out the echo's to stop showing the debug text
  16. function debug($details) {
  17. if ($details != "") {
  18.  echo $details . "<br />";
  19. } else {
  20.  echo "<hr />";
  21. }
  22. }
  23.  
  24. ?>
  25.  
  26. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  27. <html xmlns="http://www.w3.org/1999/xhtml">
  28. <head>
  29.    <title>Untitled Document</title>
  30. <link href="css.css" rel="stylesheet" type="text/css" />
  31. </head>
  32.  
  33. <body>
  34. <h1>There was a problem!!</h1>
  35.  
  36. <?php
  37. if (!isset($_SESSION["uploadFilename"]) || $_SESSION["uploadFilename"] == "") { 
  38.     ?>
  39. <p>There was an error with your upload. Please go back and try again.</p>
  40. <p>&nbsp;</p>
  41.  
  42. <?php
  43. } else { 
  44.  
  45. // set up the storage folders
  46. include("paths.php");
  47.  
  48. $storeFilename = $_SESSION["uploadFilename"];
  49.  
  50. $storePath = $storeFolder . $storeFilename;
  51. $workingPath = $workingFolder . storeFilename;
  52.  
  53. debug("Uploaded filename: ". $storePath);
  54.  
  55. // resize the image so that the shortest side is 350px to send to the flash
  56. $shortestSide = 350;
  57. $imgSize = getimagesize($storePath);
  58.  
  59. // memory calculation from http://forums.devnetwork.net/viewtopic.php?t=44550
  60. $memoryNeeded = round( (($imgSize[0] * $imgSize[1] * $imgSize['bits'] * $imgSize['channels'] / 8 + Pow(2, 16)) * 1.8) );
  61.  
  62. debug("We will need ". ($memoryNeeded/1024/1024) ."MB of memory to open the image.");
  63.  
  64. //-- need to add something here that stops the script if the memory required is greater than what's allocated.
  65.  
  66. $imgWidth = $imgSize[0];
  67. $imgHeight = $imgSize[1];
  68.  
  69. debug("The original image is ". $imgWidth ."px &times; ". $imgHeight ."px.");
  70.  
  71. //-- do we have a minimum image size?
  72.  
  73. if ($imgHeight > $imgWidth) {
  74.  
  75. // height is greater than width
  76. $ratio = 1/($imgWidth/$shortestSide);
  77.  
  78. debug("It's height is greater than width.");
  79. } else {
  80.  
  81. // height is less than or equal to the width
  82. $ratio = 1/($imgHeight/$shortestSide);
  83.  
  84. debug("It's height is less than or equal to the width.");
  85.             }
  86.  
  87. debug("Resize ratio: ". number_format($ratio,3) ." (to 3 dp).");
  88.  
  89. // calculate new size
  90. $newWidth = round($imgWidth * $ratio);            
  91. $newHeight = round($imgHeight * $ratio);
  92.  
  93. debug("The new image is ". $newWidth ."px &times; ". $newHeight ."px.");
  94.  
  95. ini_set('memory_limit', (104857600*3)); // reserve 300mb of memory to resize big pictures
  96.  
  97. // resize and save the working image
  98. $ext = strtolower(end(explode('.', $storePath)));
  99. debug("File is a ". strtoupper($ext));
  100.  
  101. if ( (strtolower($ext)=="jpg") || (strtolower($ext)=="jpeg") ) {
  102. $imgOriginal = imagecreatefromjpeg($storePath);
  103.  
  104. } elseif (strtolower($ext)=="gif") {
  105. $imgOriginal = imagecreatefromgif($storePath);
  106.  
  107. } elseif (strtolower($ext)=="png") {
  108. $imgOriginal = imagecreatefrompng($storePath);
  109.  
  110. } else {
  111. debug("Uploaded file didn't appear to be a web safe image.");
  112. ob_end_flush();
  113. exit(0);
  114. }
  115.  
  116.  
  117. //I can't help but feel something is missing from here. Badvoc added comment
  118.  
  119.  
  120. $imgNew = imagecreatetruecolor($newWidth, $newHeight);
  121.  
  122. debug("If there is a fatal error below please make your image smaller and try again!");
  123.  
  124. imagecopyresampled($imgNew, $imgOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $imgWidth, $imgHeight); 
  125.  
  126. ini_restore('memory_limit'); // put the memory limit back to it's default
  127.  
  128.  
  129.  
  130. if (is_writable($workingFolder)) {
  131. $done = imagejpeg($imgNew, $workingFolder . $storeFilename , 90);
  132.  
  133. if ($done == TRUE) {
  134. debug("New image saved to: " . $storeFilename);
  135. header('Location: step2.php?filename=' . $storeFilename);
  136.  
  137. //The following line was originally commented out but uncommenting has not made any difference...yet. Badvoc added comment
  138. echo '<a href="step2.php?filename='. $storeFilename .'">Continue&hellip;</a>';
  139. ?>
  140.  
  141. <?php } else { ?>
  142. <p>We weren't able to store the image on our server.</p>
  143. <?php
  144. }
  145. } else { ?>
  146. <p>The working folder isn't writable!</p>
  147. <?php }
  148.     }
  149.  
  150. ob_end_flush();
  151. ?>
  152.  
  153. </body>
  154. </html>
  155.  
  156.  
Sorry if this is a bit long but I wanted to provide everyone with as much info as possible.

Many thanks

Badvoc
Sep 9 '07 #1
Share this Question
Share on Google+
44 Replies

P: 44
Additional.

I have noticed in phpmyadmin that i have 2 warning messages. I'm not sure if they will have anything to do with my problem.


The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.
and

Your PHP MySQL library version 5.0.27 differs from your MySQL server version 5.0.22. This may cause unpredictable behavior
Again many thanks
Sep 9 '07 #2

kovik
Expert 100+
P: 1,044
Yikes. That post is too long, so I didn't read all of it. I did notice that you said that you got an error stating that imagecreatefromjpeg() doesn't exist. This means that the GD library is not properly set up.

What PHP version are you using?
Sep 9 '07 #3

P: 44
Yikes. That post is too long, so I didn't read all of it. I did notice that you said that you got an error stating that imagecreatefromjpeg() doesn't exist. This means that the GD library is not properly set up.

What PHP version are you using?
Again I do apologise for the lenght. I looked into posting an image of the code but it didn't workout.

Thanks for the response though.

I have called phpinfo.php and it says php version 5.1.6.

Is this the right info you require?
Sep 9 '07 #4

kovik
Expert 100+
P: 1,044
Mmhmm.

Is this local or hosted? If it's hosted, you'll need to talk with your host about why they do not have the GD library installed, as it is standard with PHP5.
Sep 9 '07 #5

P: 44
Mmhmm.

Is this local or hosted? If it's hosted, you'll need to talk with your host about why they do not have the GD library installed, as it is standard with PHP5.

Hi

It is hosted but on a dedicated server. I have just transfered it to the dedicated as this is what my friend was about to do. Would this mean that I have to install the GD library myself?

Thanks.
Sep 9 '07 #6

pbmods
Expert 5K+
P: 5,821
Heya, badvoc.

If you've got a dedicated server, then it would likely be up to you to reconfigure PHP. You can get in touch with your hosting support team to see if they'll do it for you (for free, at any rate).
Sep 9 '07 #7

P: 44
Heya, badvoc.

If you've got a dedicated server, then it would likely be up to you to reconfigure PHP. You can get in touch with your hosting support team to see if they'll do it for you (for free, at any rate).

Cheers for the reply. I am sorry but I am a total noob at this. I have rang my support team and they are not able to give support on phpadmin other than what they have in their documentation, this only gives brief details, download the latest version of phpadmin, unzip it, rename the folder and ftp it to the server. I have done this and can contect to the database fine. Its just when my site comes to image manipulation thats I get the error message.

I don't seem to be having much luck in finding a no nonesense idiots guide to getting the GD library configured in my phpadmin. The old server, a shared host, is running v2.6.0, the latest is 2.11.0. (If I am stating the obvious, apologies). I am lead to believe that the GD libs are not standard with this release, are they with any release?

Is there a way that I can download them and then ftp them to the server. Or is it more technical that that.

Many thanks for you help.
Sep 9 '07 #8

pbmods
Expert 5K+
P: 5,821
Heya, badvoc.

Alrightey. First thing to do is to create a new page on your server:
Expand|Select|Wrap|Line Numbers
  1. <?php phpinfo(); ?>
  2.  
Run that script and copy what comes up next to 'configure'.

For example (yours will very likely look different than this):
Expand|Select|Wrap|Line Numbers
  1. './configure' '--cache-file=config.cache' '--enable-shared' '--disable-static' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-libxml-dir=/usr/local' '--with-openssl=/usr/local/ssl' '--with-pcre-regex=/usr/local' '--with-zlib-dir=/usr/local' '--with-db4=/usr/local/berkeleydb' '--with-libxml-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr/local' '--with-gd' '--with-iconv=/usr/local' '--with-mysql=/usr/local/mysql' '--with-curl' '--enable-mbstring'
  2.  
Next, download the latest release of PHP to your server. SSH into your dedicated server and type:
Expand|Select|Wrap|Line Numbers
  1. curl http://www.php.net/get/php-5.2.4.tar.bz2/from/this/mirror -o php-5.2.4.tar.bz2
  2. bunzip2 php-5.2.4.tar.bz2
  3. tar -xf php-5.2.4.tar
  4. cd php-5.2.4
  5.  
Then paste the configure line and add '--with-gd' to the end of it. Press return and watch it go.

If at any point it doesn't finish successfully, post back and we'll help you out.

Next execute 'make', then 'make test'. Follow the prompts.

If not too many of the tests fail, execute the following commands:
Expand|Select|Wrap|Line Numbers
  1. apachectl stop
  2. make install
  3. apachectl start
  4.  
If you have any q's or c's post back, and we'll help you out.
Sep 9 '07 #9

P: 44
Heya, badvoc.

Alrightey. First thing to do is to create a new page on your server:
Expand|Select|Wrap|Line Numbers
  1. <?php phpinfo(); ?>
  2.  
Run that script and copy what comes up next to 'configure'.

For example (yours will very likely look different than this):
Expand|Select|Wrap|Line Numbers
  1. './configure' '--cache-file=config.cache' '--enable-shared' '--disable-static' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-libxml-dir=/usr/local' '--with-openssl=/usr/local/ssl' '--with-pcre-regex=/usr/local' '--with-zlib-dir=/usr/local' '--with-db4=/usr/local/berkeleydb' '--with-libxml-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr/local' '--with-gd' '--with-iconv=/usr/local' '--with-mysql=/usr/local/mysql' '--with-curl' '--enable-mbstring'
  2.  
Next, download the latest release of PHP to your server. SSH into your dedicated server and type:
Expand|Select|Wrap|Line Numbers
  1. curl http://www.php.net/get/php-5.2.4.tar.bz2/from/this/mirror -o php-5.2.4.tar.bz2
  2. bunzip2 php-5.2.4.tar.bz2
  3. tar -xf php-5.2.4.tar
  4. cd php-5.2.4
  5.  
Then paste the configure line and add '--with-gd' to the end of it. Press return and watch it go.

If at any point it doesn't finish successfully, post back and we'll help you out.

Next execute 'make', then 'make test'. Follow the prompts.

If not too many of the tests fail, execute the following commands:
Expand|Select|Wrap|Line Numbers
  1. apachectl stop
  2. make install
  3. apachectl start
  4.  
If you have any q's or c's post back, and we'll help you out.

Thanks, I am trying this now. I have resest the password and have to wait an hour.

Is there another way to do or does it have to be done via ssh?

Cheers
Sep 9 '07 #10

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Does your server have cPanel installed?
Sep 9 '07 #11

P: 44
Heya, Badvoc.

Does your server have cPanel installed?
No I'm afraid not. I have been intouch with the support team and they are resending the account details so hopefully I should be set to go via ssh shortly.

Cheers
Sep 10 '07 #12

P: 44
Hi,

I have run the phpinfo and copied the result as described. I have added --gd at the end.

I have carried out the following

curl http://www.php.net/get/php-5.2.4.tar.bz2/from/this/mirror -o php-5.2.4.tar.bz2
bunzip2 php-5.2.4.tar.bz2
tar -xf php-5.2.4.tar
cd php-5.2.4
I have then run the configure info i got from phpinfo as described and this is what i got.

creating cache ../config.cache
checking for Cygwin environment... no
checking for mingw32 environment... no
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking host system type... i386-redhat-linux-gnu
checking target system type... i386-redhat-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for icc... no
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for AIX... no
checking whether ln -s works... yes
checking for system library directory... lib
checking whether to enable runpaths... no
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking for re2c... no
configure: warning: You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for bison... bison -y
checking for bison version... 2.3 (ok)
checking for flex... flex
checking for yywrap in -lfl... yes
checking lex output file root... lex.yy
checking whether yytext is a pointer... yes
checking for working const... yes
checking for flex version... 2.5.4 (ok)
checking whether to force non-PIC code in shared modules... no
checking whether /dev/urandom exists... yes
checking for pthreads_cflags... -pthread
checking for pthreads_lib...

Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... no
checking for Apache 1.x module support... no
checking whether to enable Apache charset compatibility option... no
checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS...

Sorry, I cannot run apxs. Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/sbin/apxs follows:
./configure: line 6669: /usr/sbin/apxs: No such file or directory
configure: error: Aborting
Am I on the right lines or is something else missing?

Many thnaks for the help.
Sep 10 '07 #13

P: 44
I have run the following to

1.apachectl stop
2. make install
3. apachectl start
and got this messages back respectivly.

[warn] NameVirtualHost 88.208.234.21:80 has no VirtualHosts

make: *** No rule to make target `install'. Stop.

[warn] NameVirtualHost 88.208.234.21:80 has no Virtua
lHosts

Thanks
Sep 10 '07 #14

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

What version of Apache are you running?

Run this command:
Expand|Select|Wrap|Line Numbers
  1. httpd -v
  2.  
What does your configure string (./configure --config-cache=config.cache...) look like?

I'm going to go ahead and move this thread to the *n?x forum, where our resident Experts will be better able to help you out.
Sep 10 '07 #15

P: 44
Heya, Badvoc.

What version of Apache are you running?

Run this command:
Expand|Select|Wrap|Line Numbers
  1. httpd -v
  2.  
What does your configure string (./configure --config-cache=config.cache...) look like?

I'm going to go ahead and move this thread to the *n?x forum, where our resident Experts will be better able to help you out.

Cheers.

Apache is version 2.2.0

The configure string is as follows.

'./configure' '--build=i386-redhat-linux' '--host=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/etc/httpd/conf/magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'
Sep 11 '07 #16

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Interesting. It seems that the configure script can't find apxs in /usr/sbin. Which is odd because presumably you had a working installation before....

Ahhh, I love preconfigured servers.

Ok. I wonder what this outputs:
Expand|Select|Wrap|Line Numbers
  1. find /usr -name 'apxs'
  2.  
Sep 11 '07 #17

P: 44
Heya, Badvoc.

Interesting. It seems that the configure script can't find apxs in /usr/sbin. Which is odd because presumably you had a working installation before....

Ahhh, I love preconfigured servers.

Ok. I wonder what this outputs:
Expand|Select|Wrap|Line Numbers
  1. find /usr -name 'apxs'
  2.  

Hi,

that did nothing. Just returned the command prompt in the same level of the directory.

I am glad you love preconfigured servers...I am begining to hate them, but I am sure I will learn to love in due course.

Thanks


Edit:

i am in the usr/sbin folder and there are no files named apxs.
Sep 11 '07 #18

P: 44
Hi, I have added the following to the files that are not working as they should.

<?php
error_reporting(E_ALL);
ini_set('display_errors', True);
?>
I am now getting this aswell which may be of use/interest.

Due to the amount of code I have posted an image.





Sorry for the poor quality, if you need the code in writing let me know and I'll post it.

Again many thanks.
Sep 11 '07 #19

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Hm.

Looks like you have PHP running in safe mode.

You'll want to disable that. Your php.ini file should be located at /etc/php.ini. Simply change this line:
Expand|Select|Wrap|Line Numbers
  1. safe_mode = On
  2.  
to:
Expand|Select|Wrap|Line Numbers
  1. safe_mode = Off
  2.  
Sep 11 '07 #20

P: 44
Heya, Badvoc.

Hm.

Looks like you have PHP running in safe mode.

You'll want to disable that. Your php.ini file should be located at /etc/php.ini. Simply change this line:
Expand|Select|Wrap|Line Numbers
  1. safe_mode = On
  2.  
to:
Expand|Select|Wrap|Line Numbers
  1. safe_mode = Off
  2.  
Looks like I am catching on. I am currently editing the php.ini file now.

Does this need editing in anyway.

I have read that i need to create a tmp directory somewhere on the server but not sure where.
Safe mode is now off but i have checked and there seems to be more than one php.ini file on the server. Do i need to change these to?

Cheers.
Cheers
Sep 11 '07 #21

P: 44
I have an update for you.


I have edited the php.ini file and when i run the phpinfo.php it shows the changes ecept for safe mode. It still show it as on. I have changed it to off and made sure it is uncommented.

Any ideas?

Thanks
Sep 12 '07 #22

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

You have a dedicated server... so therefore you should be able to change this value. I can't imagine that your hosting provider configured your server to prevent you from turning safe mode off....

Hm.

Check your phpinfo() script again. Look for "Configuration File (php.ini) Path" and/or "Loaded Configuration File". Make sure you're editing the correct file.

You may also need to restart Apache for the changes to take effect.
Sep 12 '07 #23

P: 44
Heya, Badvoc.

You have a dedicated server... so therefore you should be able to change this value. I can't imagine that your hosting provider configured your server to prevent you from turning safe mode off....

Hm.

Check your phpinfo() script again. Look for "Configuration File (php.ini) Path" and/or "Loaded Configuration File". Make sure you're editing the correct file.

You may also need to restart Apache for the changes to take effect.
Ok, that has been done, I had forgotten to restart apache.

Running phpinfo I can now see my changes have taken effect.

I am still getting the following error though.

Warning: getimagesize() [[color=#0066cc]function.getimagesize[/color]]: open_basedir restriction in effect.

File(/Testing/thumbs/A.gif) is not within the allowed path(s): (/tmp:/home/default/mypage.co.uk) in /home/default/mypage.co.uk/user/htdocs/Testing/step1.php on line 57
The open_basedir is set as, according to phpinfo,
/tmp:/home/default/mypageco.uk (local value) Master value is set to no value.

Could this be the underlying problem?

Many thanks...I do feel as I am learning here.
Sep 12 '07 #24

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Have a look at this page. It looks like open_basedir operates independently of safe mode.
Sep 12 '07 #25

P: 44
Heya, Badvoc.

Have a look at this page. It looks like open_basedir operates independently of safe mode.
Yeah, i have come accross this page earlier toady. I have tried to change the open_basedir.

This is how it looks in phpinfo.

open_basedir/tmp:/home/default/yourimage2canvas.co.uk

none


The first value is local and as far as I have found out, fixed. I can only change the master value, currently "no value". I have set it to the same as the local vaue and I have seen some suggestions for setting it to /var/tmp but this has not helped either. All the folders I am using fall under the first directory anyway.

I am currently searching for a way to turn of the open_basedir restriction.

Thanks again
Sep 13 '07 #26

P: 44
Just something I have seen and wondered if this might make a difference.

Whilst restarting httpd service i get this message.
Starting httpd: [Thu Sep 13 01:07:09 2007] [warn] NameVirtualHost 88.208.234.21:80 has no VirtualHosts
[ OK ]
Whilst going over many sites about this topic people keep mentioning v host. Should I have set a virtual host up?
Sep 13 '07 #27

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

The default value for open_basedir is null, so simply comment it out:
Expand|Select|Wrap|Line Numbers
  1. ;open_basedir = 
  2.  
As far as the virtual host warning, it's (mostly) harmless. The error means that you are listening for named virtual hosts, even though you have none set up. At worst, your server is spinning off a few extra CPU cycles per request. Once you have PHP working properly, we'll tackle that.
Sep 13 '07 #28

P: 44
Ok, I have reset open_basedir to the values you said but I am still getting this from phpinfo.

open_basedir
/tmp:/home/default/yourimage2canvas.co.uk

no value
I have run phpinfo for the old shared hosted server and both local and master values are set to no value.

Any ideas how to alter the local value?

Thanks
Sep 13 '07 #29

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

And you restarted Apache after making this change, correct?
Sep 13 '07 #30

P: 44
I think so. I am executing service httpd restart via a ssh command.

I have found a file called vhost.conf. This has the local value for the open_basedir.

I'll see if it can be set to no value.....
Sep 13 '07 #31

P: 44
We have a result. The value now shows as / and the open_basedir restriction errors have now gone.

I am left with

Warning: getimagesize(/Testing/thumbs/A.gif) [[color=#0066cc]function.getimagesize[/color]]: failed to open stream: No such file or directory in /home/default/yourimage2canvas.co.uk/user/htdocs/Testing/step1.php on line 57

I am getting other warnings of a similar nature but I feel if this one is fixed then I should be good to go.

I have remove error reproting script that i had in my code. All errors Have no gone, or I should say are no longer visible. Am I best to leave the error reporting on and try and fix them?
Sep 13 '07 #32

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Try prepending $_SERVER['DOCUMENT_ROOT'] to the file path, e.g.:
Expand|Select|Wrap|Line Numbers
  1. $_info = getimagesize($_SERVER['DOCUMENT_ROOT'] . '/Testing/thumbs/A.gif');
  2.  
Sep 13 '07 #33

P: 44
Forgive me for sounding thick but where do I put that line?

$_info = getimagesize($_SERVER['DOCUMENT_ROOT']
$imgSize = getimagesize($storePath);

I have put it here and all i get now is a blank screen.
Sep 13 '07 #34

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

I was just putting up an example. On line 57 of step1.php, you're trying to getimagesize() on '/Testing/thumbs/A.gif' (possibly the value of a variable there), which PHP is looking for at the root level of your server's filesystem instead of the root of your website.

Prepending $_SERVER['DOCUMENT_ROOT'] to the of the image would make PHP look for the image now in '/home/default/yourimage2canvas.co.uk/user/htdocs/Testing/thumbs/A.gif', which I suspect is where the image *really* is.
Sep 13 '07 #35

P: 44
Ok, I am still a little lost but will investigate this tomorrow.

I do have a file that that I include in step1 which defines the paths of the 2 folder variables.

[PHP] <?php
$storeFolder = "/Testing/uploads/";
$workingFolder = "/Testing/thumbs/";
define('BASE_HREF', 'http://www.yourimage2canvas.co.uk/');
?>
[/PHP]

Is this on the same lines as you were talking? Would this do the same job?

The idea is that a picture is uploaded and then step1 resizes the image, stores it in another folder and is then used in a flash application as part of step2.

Many thanks for your help its very much appreciated.
Sep 13 '07 #36

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Change this:
Expand|Select|Wrap|Line Numbers
  1. $_info = getimagesize($_SERVER['DOCUMENT_ROOT']
  2. $imgSize = getimagesize($storePath);
  3.  
To this:
Expand|Select|Wrap|Line Numbers
  1. $imgSize = getimagesize($_SERVER['DOCUMENT_ROOT'] . $storePath);
  2.  
Sep 13 '07 #37

P: 44
Hi,

I have been working on anotherpart of the site and got the same error messages after making a change. So I undid the changes and uploaded these files to a test folder on the dedicated server and all seems good.

I am going to run a real test on the main url for the site this evening.

I think it is something to do with the paths to the upload folder, I must have had it coded slightly different and with the changes I, sorry we, were making to the server settings it seems to have sorted it.

I will post again later when I have tried it. If it fails I will edit with the details you have posted.

Many thanks.
Sep 13 '07 #38

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Good luck. We'll be here if anything explodes. Unless we're what explodes. Then we won't.
Sep 13 '07 #39

P: 44
Hi, Well I think it is I who is going to explode.

I am now running the site at the following 2 urls.

www.yourimage2canvas.co.uk/order.php

and

www.yourimage2canvas.co.uk/Testing/order.php

The second of the is working fine. So I have ftp'd all the files to the main directory ensuring overwrite takes place and I get the following error.

Please ensure you have Adobe Flash Player installed. ([color=#800080]Download Flash[/color])

In the bottom left of the screen I have an "error on page" message. This reads as follows.

Line: 23
Char: 5
'Error: SWFUpload' is undefined.
Code:0
URL: http://www.yourimage2canvas.co.uk/order.php

the file order.php involves a browse box and a flash uploading bar. When order.php is accessed from the main url i get the error but when accessed url/Testing I get no errors.

Apologies for this moving slightly away from the topic but this can't be a flash issue as all other flash files are working.

I am very confused as to why the browse box won't load on one page but does on another.

Any ideas?

Thanks.
Sep 13 '07 #40

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

You probably either didn't upload the .js file that defines the SWF loader, or else (more likely) the file has incorrect permissions.

Locate the file and execute the following command in the shell:
Expand|Select|Wrap|Line Numbers
  1. chmod 755 /path/to/swf/upload/loader.js
  2.  
Sep 13 '07 #41

P: 44
I hate to say it but the files are there and both have permissions set to 755.

I have even tried 777 but no good.

I don't understand why, when i have exactly the same files on the same server just at a sub level in the file directory, I get the error message.

Would it be worth deleting the whole lot from the server and re uploading it. (back ups made!!!)

Thanks
Sep 13 '07 #42

P: 44
We have a winner.

Sorted it. With you mentioning permssions I noticed that the permissions on the folders in the Testing folder were all 777. I have set all the folders in the main directory to the same and it works. I will now test which ones need to have those levels of permission and reset the others.

Many thanks for you time and help. Its very much appreciated.

Badvoc
Sep 13 '07 #43

pbmods
Expert 5K+
P: 5,821
Heya, Badvoc.

Good call.

Good luck with your project, and if you ever need anything, post back anytime :)
Sep 13 '07 #44

P: 44
Thanks,

I have a big project coming up shortly so I'll be sure to stop by.

Thanks again

Badvoc
Sep 13 '07 #45

Post your reply

Sign in to post your reply or Sign up for a free account.