Jump to content

Image Upload


phpretard

Recommended Posts

This is the script I'm using to upload images.  Is there something I can add to resize the image proportionaly so that is fits on the page where it is later echoed? 

 

or

 

Can I set a max width / height when displayed?

 

 

function findexts ($filename) 
{ 
$filename = strtolower($filename) ; 
$exts = split("[/\\.]", $filename) ; 
$n = count($exts)-1; 
$exts = $exts[$n]; 
return $exts; 
} 

$ext = findexts ($_FILES['uploaded']['name']) ; 

$ran = rand (111111, 999999). $company ;

$ran2 = $ran.".";

$target = "pages/secure/partners/img/";

$target = $target . $ran2.$ext;

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{

mysql_query("INSERT INTO partners (id, company, url, uploaded, blurb ) 
VALUES ('', '$company', '$url', '$target', '$blurb')");

$success="<center><font color=red size=2>Upload Successful!</font><br><br></center>";

}

Link to comment
https://forums.phpfreaks.com/topic/108506-image-upload/
Share on other sites

Use the GD PHP Extension here is a simple script to resize an image

 

 

<?php

// Load image
$image = open_image('flower.jpg');
if ($image === false) { die ('Unable to open image'); }

// Get original width and height
$width = imagesx($image);
$height = imagesy($image);

// New width and height
$new_width = 150;
$new_height = 100;

// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Display resized image
header('Content-type: image/jpeg');
imagejpeg($image_resized);
die();

?>

Link to comment
https://forums.phpfreaks.com/topic/108506-image-upload/#findComment-556347
Share on other sites

I am really trying to keep this as simple as possible.

 

I have many different size images in different formats in a file and just want to display them with a max height and width.

 

I tried CSS well... IE is IE (works great in FF).

 

Is there a simple way?

 

Link to comment
https://forums.phpfreaks.com/topic/108506-image-upload/#findComment-556383
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.