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 -
-
<?php
-
error_reporting(E_ALL);
-
ini_set('display_errors', True);
-
?>
-
-
to the step1.php file and this reported the following error. -
-
Fatal error: Call to undefined function imagecreatefromjpeg()
-
-
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. -
-
if ( (strtolower($ext)=="jpg") || (strtolower($ext)=="jpeg") ) {
-
$imgOriginal = imagecreatefromjpeg($storePath);
-
-
} elseif (strtolower($ext)=="gif") {
-
$imgOriginal = imagecreatefromgif($storePath);
-
-
} elseif (strtolower($ext)=="png") {
-
$imgOriginal = imagecreatefrompng($storePath);
-
-
} else {
-
debug("Uploaded file didn't appear to be a web safe image.");
-
-
ob_end_flush();
-
exit(0);
-
}
-
-
I am not sure if this is enough information so I will add the entire step1.php for assistance. -
-
<?php
-
error_reporting(E_ALL);
-
ini_set('display_errors', True);
-
?>
-
-
-
<?php
-
session_start();
-
ob_start();
-
-
// javascript was required so the user will never use the degraded version
-
$used_degraded = false;
-
-
// my debug function. comment out the echo's to stop showing the debug text
-
function debug($details) {
-
if ($details != "") {
-
echo $details . "<br />";
-
} else {
-
echo "<hr />";
-
}
-
}
-
-
?>
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<title>Untitled Document</title>
-
<link href="css.css" rel="stylesheet" type="text/css" />
-
</head>
-
-
<body>
-
<h1>There was a problem!!</h1>
-
-
<?php
-
if (!isset($_SESSION["uploadFilename"]) || $_SESSION["uploadFilename"] == "") {
-
?>
-
<p>There was an error with your upload. Please go back and try again.</p>
-
<p> </p>
-
-
<?php
-
} else {
-
-
// set up the storage folders
-
include("paths.php");
-
-
$storeFilename = $_SESSION["uploadFilename"];
-
-
$storePath = $storeFolder . $storeFilename;
-
$workingPath = $workingFolder . storeFilename;
-
-
debug("Uploaded filename: ". $storePath);
-
-
// resize the image so that the shortest side is 350px to send to the flash
-
$shortestSide = 350;
-
$imgSize = getimagesize($storePath);
-
-
// memory calculation from http://forums.devnetwork.net/viewtopic.php?t=44550
-
$memoryNeeded = round( (($imgSize[0] * $imgSize[1] * $imgSize['bits'] * $imgSize['channels'] / 8 + Pow(2, 16)) * 1.8) );
-
-
debug("We will need ". ($memoryNeeded/1024/1024) ."MB of memory to open the image.");
-
-
//-- need to add something here that stops the script if the memory required is greater than what's allocated.
-
-
$imgWidth = $imgSize[0];
-
$imgHeight = $imgSize[1];
-
-
debug("The original image is ". $imgWidth ."px × ". $imgHeight ."px.");
-
-
//-- do we have a minimum image size?
-
-
if ($imgHeight > $imgWidth) {
-
-
// height is greater than width
-
$ratio = 1/($imgWidth/$shortestSide);
-
-
debug("It's height is greater than width.");
-
} else {
-
-
// height is less than or equal to the width
-
$ratio = 1/($imgHeight/$shortestSide);
-
-
debug("It's height is less than or equal to the width.");
-
}
-
-
debug("Resize ratio: ". number_format($ratio,3) ." (to 3 dp).");
-
-
// calculate new size
-
$newWidth = round($imgWidth * $ratio);
-
$newHeight = round($imgHeight * $ratio);
-
-
debug("The new image is ". $newWidth ."px × ". $newHeight ."px.");
-
-
ini_set('memory_limit', (104857600*3)); // reserve 300mb of memory to resize big pictures
-
-
// resize and save the working image
-
$ext = strtolower(end(explode('.', $storePath)));
-
debug("File is a ". strtoupper($ext));
-
-
if ( (strtolower($ext)=="jpg") || (strtolower($ext)=="jpeg") ) {
-
$imgOriginal = imagecreatefromjpeg($storePath);
-
-
} elseif (strtolower($ext)=="gif") {
-
$imgOriginal = imagecreatefromgif($storePath);
-
-
} elseif (strtolower($ext)=="png") {
-
$imgOriginal = imagecreatefrompng($storePath);
-
-
} else {
-
debug("Uploaded file didn't appear to be a web safe image.");
-
ob_end_flush();
-
exit(0);
-
}
-
-
-
//I can't help but feel something is missing from here. Badvoc added comment
-
-
-
$imgNew = imagecreatetruecolor($newWidth, $newHeight);
-
-
debug("If there is a fatal error below please make your image smaller and try again!");
-
-
imagecopyresampled($imgNew, $imgOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $imgWidth, $imgHeight);
-
-
ini_restore('memory_limit'); // put the memory limit back to it's default
-
-
-
-
if (is_writable($workingFolder)) {
-
$done = imagejpeg($imgNew, $workingFolder . $storeFilename , 90);
-
-
if ($done == TRUE) {
-
debug("New image saved to: " . $storeFilename);
-
header('Location: step2.php?filename=' . $storeFilename);
-
-
//The following line was originally commented out but uncommenting has not made any difference...yet. Badvoc added comment
-
echo '<a href="step2.php?filename='. $storeFilename .'">Continue…</a>';
-
?>
-
-
<?php } else { ?>
-
<p>We weren't able to store the image on our server.</p>
-
<?php
-
}
-
} else { ?>
-
<p>The working folder isn't writable!</p>
-
<?php }
-
}
-
-
ob_end_flush();
-
?>
-
-
</body>
-
</html>
-
-
Sorry if this is a bit long but I wanted to provide everyone with as much info as possible.
Many thanks
Badvoc
44 9560
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
kovik 1,044
Recognized Expert Top Contributor
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 imagecreatefrom jpeg() doesn't exist. This means that the GD library is not properly set up.
What PHP version are you using?
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 imagecreatefrom jpeg() 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?
kovik 1,044
Recognized Expert Top Contributor
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.
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.
pbmods 5,821
Recognized Expert Expert
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).
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.
pbmods 5,821
Recognized Expert Expert
Heya, badvoc.
Alrightey. First thing to do is to create a new page on your server:
Run that script and copy what comes up next to 'configure'.
For example (yours will very likely look different than this): -
'./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'
-
Next, download the latest release of PHP to your server. SSH into your dedicated server and type: -
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
-
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: -
apachectl stop
-
make install
-
apachectl start
-
If you have any q's or c's post back, and we'll help you out.
Heya, badvoc.
Alrightey. First thing to do is to create a new page on your server:
Run that script and copy what comes up next to 'configure'.
For example (yours will very likely look different than this): -
'./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'
-
Next, download the latest release of PHP to your server. SSH into your dedicated server and type: -
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
-
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: -
apachectl stop
-
make install
-
apachectl start
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mike |
last post by:
Looking to find any information on how to properly configure multiple
instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking
for information on how the multiple instance settings should
configured to work, how memory is shared or not, etc. I can not seem
to find any good links to this information.
Thanks,
Mike
|
by: Ed Stevens |
last post by:
A tale of woe, and a question . . .
Last week my boss said to me "we've installed DB2 Connect on this
Solaris box. Make it work."
Now, I've barely seen DB2 Connect on Windows, having fumbled thru one
install and config, with a lot of handholding from IBM Support. I'm
comfortable in unix but have never dealt with DB2 Connect there. (my
main job is as an Oracle DBA, and most of my db's are on Solaris or
AIX) I've found the install...
|
by: Ron Weldy |
last post by:
So far, every book I have looks at on ASP.NET jumps right into creating a
project. There is no discussion about setting up the environment, using a
local IIS install (I think it can all be ran on XP now, right?) vs. having a
development server, etc. I will want to eventually maintain several websites
using ASP.NET and SQL Server and I have my own development box with W2003
server and IIS6 running.
Anybody got some good reference material...
|
by: Jack Orenstein |
last post by:
I'm trying to configure PHP 5.2.0 with support for Postgres
8.1.3. Postgres was installed with FC5 without source. PHP's configure
needs source. When I run configure:
configure: error: Cannot find libpq-fe.h. Please specify
correct PostgreSQL installation path
I tried downloading Postgres source and modifying PHPs configure to
point to it, and that worked. But then compilation failed, e.g.
|
by: Scubadude |
last post by:
I am looking for some assistance in 'fine-tuning' my preferences as I set-up
my system to learn PHP.
I am running Komodo professional, version 3.5.3, build 262321, platform
win32-x86.
Under Preferences/Language/PHP in debugger configuration, I am getting the
following error message:
WARNING! PHP is not configured for debugging. You can use the configuration
wizard to configure PHP for debugging.
| |
by: RoyScripts |
last post by:
Hi All..
I really need help configuring PHP with GD support. I am running Fedora 6, Apache and PHP 5.1.6, i have downloaded the gd-2.0.35 file and unpacked it under the directory /usr/lib/php/gd-2.0.35. I followed the instructions to install it which is as follows. Firstly ./configure --with-gd then make and lastly make install.. Everything installed with no errors. But now when i look at the phpinfo i still get the --without-gd. I really am...
|
by: pbmods |
last post by:
Configuring PHP 5.2.3 with GD support for Mac OS X
PHP 5.2.3 does not seem to want to configure with GD support on Mac OS X for some reason. When configuring, you may notice this error:
configure: error: GD build test failed. Please check the config.log for details.
Checking config.log yields the following:
configure:42434: gcc -o conftest -g -O2 -no-cpp-precomp -L/usr/local/lib -L/usr/local/lib conftest.c -L -lfreetype -lpng...
|
by: rada.lambretha |
last post by:
Configuring Linux as a Firewall
* Making installation choices
* Introducing iptables
* Using iptables commands
* Simplifying things with firewall GUIs
* Adding proxy functionality
As Linux gains increasing acceptance in corporate datacenters and
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |