CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Upload images and thumbs

Print topic Send  topic

Author Message
Enrique
Posted: 01/17/2004, 7:25 AM

Here a code to process an uploaded file and make thumb.

Put this in "After Process File"
I
---> Custom Code

The complete function is :

function productos_FileUpload1_AfterProcessFile()
{
global $productos;
$productos_FileUpload1_AfterProcessFile = true;
//End productos_FileUpload1_AfterProcessFile
// -------------------------
crearthumb ($productos->FileUpload1->FileFolder.$productos->FileUpload1->Value,"../thumbs/".$productos->FileUpload1->Value,80,80);
//Custom Code @13-865E2CCD
// Write your own code here.
// -------------------------
//End Custom Code

//Close productos_FileUpload1_AfterProcessFile @12-8B464092
return $productos_FileUpload1_AfterProcessFile;
}



my "crearthumb" function is--->


function crearthumb($nombre,$thnombre,$ancho,$alto)
{
global $gd2;
if (preg_match("/jpg|jpeg/",$nombre))
{
$src_img=imagecreatefromjpeg($nombre);
}
if (preg_match("/png/",$nombre))
{ $src_img=imagecreatefrompng($nombre); }
$antiguo_x=imageSX($src_img);
$antiguo_y=imageSY($src_img);
if ($antiguo_x > $antiguo_y)
{
$thumb_w=$ancho;
$thumb_h=$antiguo_y*($alto/$antiguo_x);
}
if ($antiguo_x < $antiguo_y) {
$thumb_w=$antiguo_x*($ancho/$antiguo_y);
$thumb_h=$alto;
}
if ($antiguo_x == $antiguo_y) {
$thumb_w=$ancho;
$thumb_h=$alto;
}
if ($gd2==""){
$dst_img=ImageCreate($thumb_w,$thumb_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$antiguo_x,$antiguo_y);
}else{
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$antiguo_x,$antiguo_y);
}
if (preg_match("/png/",$system[1])){
imagepng($dst_img,$thnombre);
}
else {
imagejpeg($dst_img,$thnombre);
}
imagedestroy($dst_img);
imagedestroy($src_img);

}


At top of this page....
kescott


Posts: 49
Posted: 02/03/2004, 9:03 AM

I'm getting a parse error when I publish with your code.

The message reads,"Parse error: parse error, unexpected ')' in /var/www/html/personnel/newentry_events.php on line 16
"
it is refering to

crearthumb ($productos->FileUpload1->FileFolder.$productos->FileUpload1->Value,"../thumbs/".$productos->FileUpload1->Value,80,80);

Can you help? :(
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
View profile  Send private message
feha


Posts: 712
Posted: 02/06/2004, 8:02 AM

I think there is NO SYNTAX ERROR in Enriques function ...
Check Your code please...
He forgot to mention that this images operations REQUIRE GD library
enabled in your php.ini file ...
or extenstions ...

regards
feha
www.vision.to

_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
capone
Posted: 02/16/2004, 7:47 AM

I have also use this code and it's giving me the same problem kescott
is facing.

Since "FEHA" seems to know more about how to make it work why don't you please help us on the GD library in our PHP.ini file....

Because beside the parse error it keeps pointing to an invalid function

crearthumb ($productos->FileUpload1->FileFolder.$productos->FileUpload1->Value,"../thumbs/".$productos->FileUpload1->Value,80,80);

Thank you in advance...
Kevin
Posted: 02/20/2004, 5:39 AM

:-/

Does anyone have a suitable answer to my question?
LuteD
Posted: 06/12/2004, 10:37 AM

I tried this and it works great. :-)
You have to have GD2 enabled. In your php.ini, un-comment the line:
;extension=php_gd2.dll
Also make sure your extensions diectory is set. By default it should be:
extension_dir = "./"
I changed mine to: extension_dir = "./extensions"

feha


Posts: 712
Posted: 06/22/2004, 7:08 AM

Great
:-)
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
Damian
Posted: 06/23/2004, 11:41 PM

I am having trouble getting GD2 to work on my local IIS. PHP works fine but
no GD functions.
I have copied the dll to the extensions directory and removed the ";"
I have played with many variations of the extension_dir but cannot get it to
work...

Anyone else have difficulties and managed to resolve them?

"LuteD" <LuteD@forum.codecharge> wrote in message
news:540cb3f52c97ce@news.codecharge.com...
> I tried this and it works great. :-)
> You have to have GD2 enabled. In your php.ini, un-comment the line:
> ;extension=php_gd2.dll
> Also make sure your extensions diectory is set. By default it should be:
> extension_dir = "./"
> I changed mine to: extension_dir = "./extensions"
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Visiomart

Posts: 13
Posted: 07/02/2004, 1:28 PM

Hello Guys & Gals
I have used this code and changed the page names as usual and uncommented the extention but only php_gd.ll is written there and available in my php.ini

All it keeps bringing to me is that
" cannot call to a member function imagecreatefromjpeg ()"
I wanted to know wheter i have to declare the function imagecreatefromjpeg or not I'm totally confused

Please Please if anyone can give me his version of the code or help enable mine work i will be glad to be helped by this forum..
thanks in advance

capone
_________________
Don Capone
View profile  Send private message
Visiomart

Posts: 13
Posted: 07/04/2004, 3:00 AM

Hi all
Thanks for your guidance i have been able to download the new PHP5 and the code worked great.. Thanks
_________________
Don Capone
View profile  Send private message
val
Posted: 07/07/2004, 4:30 AM

O:)O:)O:)O:)O:)O:)O:)O:)
headhunter


Posts: 130
Posted: 07/15/2004, 5:45 AM

Hi all,

everything works fine.

I just wonder how to delete the thumb when you delete an image from the database?

That code would go in the "After delete file" I think.

Thanks
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.