i have a file upload script and within it i use SimpleImage... its a image resizing function. When just used on it's on it works fine, and when i use it within a simple loop like the one below it works fine -
<?php
-
include('SimpleImage.php');
-
$add= "images/test/Desert.jpg";
-
-
$details = array();
-
$details = getimagesize($add);
-
$imgWidth = $details[0];
-
if ($imgWidth > 450){
-
$image = new SimpleImage();
-
$image->load("$add");
-
$image->resize(450,350);
-
$image->save("$add");
-
-
echo '<img src="'.$add .'" alt="test"/>';
-
} else {
-
echo $details[1].'<br/>';
-
echo $details[4].'<br/>';
-
echo $details[3].'<br/>';
-
}
-
?>
-
but when i include it into my upload script in the correct position it wont work.
this is the original script i wrote -
include('SimpleImage.php');
-
while(list($key,$value) = each($_FILES['images']['name']))
-
{
-
if(!empty($value))
-
{
-
$filename = $value;
-
$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
-
-
$add = "upload/imgtemp/m/$random_digit/$filename";
-
$tempFLDR = "upload/imgtemp/t/$random_digit/$filename";
-
//echo $_FILES['images']['type'][$key];
-
// echo "<br>";
-
copy($_FILES['images']['tmp_name'][$key], $add);
-
chmod("$add",0777);
-
copy($_FILES['images']['tmp_name'][$key], $tempFLDR);
-
chmod("$tempFLDR",0777);
-
}
-
$image = new SimpleImage();
-
$image->load("$add");
-
$image->resize(535,400);
-
$image->save("$add");
-
-
$image = new SimpleImage();
-
$image->load("$tempFLDR");
-
$image->resize(100,75);
-
$image->save("$tempFLDR");
-
}
-
and this is what i've changed it to... i've included the same loop as the 1st code in the post... i've placed it in the same position as the original within loops i've checked on a blank page to make sure it works but it keeps cutting the script short -
include('SimpleImage.php');
-
while(list($key,$value) = each($_FILES['images']['name']))
-
{
-
if(!empty($value))
-
{
-
$filename = $value;
-
$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
-
-
$add = "user/tmp/large/$eventID/$filename";
-
$tempFLDR = "user/tmp/av/$eventID/$filename";
-
//echo $_FILES['images']['type'][$key];
-
// echo "<br>";
-
copy($_FILES['images']['tmp_name'][$key], $add);
-
chmod("$add",0777);
-
copy($_FILES['images']['tmp_name'][$key], $tempFLDR);
-
chmod("$tempFLDR",0777);
-
-
}
-
-
$details = array();
-
$details = getimagesize($add);
-
$detailsWidth = details[0];
-
$detailsHeight = details[1];
-
-
if ($detailsWidth > $detailsHeight){
-
$image = new SimpleImage();
-
$image->load("$add");
-
$image->resize(450,350);
-
$image->save("$add");
-
-
$image = new SimpleImage();
-
$image->load("$tempFLDR");
-
$image->resize(100,70);
-
$image->save("$tempFLDR");
-
}
-
elseif ($detailsHeight > $detailsWidth) {
-
$image = new SimpleImage();
-
$image->load("$add");
-
$image->resize(240,350);
-
$image->save("$add");
-
-
$image = new SimpleImage();
-
$image->load("$tempFLDR");
-
$image->resize(100,100);
-
$image->save("$tempFLDR");
-
}
-
}
-
1 1597
nevermind... my illness is taking my eyes away from me or making me a clutz... my problem was here - $details = array();
-
$details = getimagesize($add);
-
$detailsWidth = details[0]; // <--- i left the $ off the variable
-
$detailsHeight = details[1]; // <--- i left the $ off the variable
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ruby Tuesday |
last post by:
I have a section(185pixelsx 185pixels) in my web page to display an image
that is stored in a directory. Using php, how do you resize so if:
the image dimension is smaller(width and height is...
|
by: Amir |
last post by:
Hi,
I'd like to know if it's possible to pass an image name (the IMG SRC
attribute) from HREF element to a function that is activated by onClick
event and creates a Web page.
I have this HREF...
|
by: Jim |
last post by:
I've heard that resizing images through PHP (either GD2 or ImageMagick)
is a processor intensive exercise. I'm setting up a site where users
will be uploading up to 10 images along with the details...
|
by: lofty00 |
last post by:
hello,
sorry about the repost - I've been posting to several groups and I've
decided it's better to make a single repost to all of them rather than
an extra post in each.
I've been trying to...
|
by: Geuis |
last post by:
Hi, new to the group.
I use the following code to resize images my users upload. They're
either blurry or they're jaggy.
Can someone recommend modifications or different code that will resize...
| |
by: aaronic |
last post by:
This is in reference to my previos post but a completely different problem.
Previous problem and code can be found here:
http://www.thescripts.com/forum/thread563724.html
When I run the...
|
by: Boricua |
last post by:
I'm using ASP.NET 2.0
I got an imagebutton at the end of my form as a submit button. When
the user clicks it the button becomes disabled and continues with the
postback.
This is what I got, ib...
|
by: Keldair via DotNetMonster.com |
last post by:
Hello all,
I am working with some barcode images using a TTF (True Type Font). I know
it is not the best method, but it is what I have available at the moment. I
have everything working all up...
|
by: barber.brad |
last post by:
We are code crushing the width of images from 285px to 260 pix.
However we aren't changing the height. we need a bit of javascript
that can make that percentage change to the height as well. Can...
|
by: spinow |
last post by:
Hi there,
My current project has a div with a table inside it. In this table I have a cell. In this cell images are loaded using a javascript function and the images are resized to fit the cell with...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |