answersLogoWhite

0

How do you upload and resize an image with PHP?

Updated: 9/14/2023
User Avatar

Mbud

Lvl 1
15y ago

Best Answer


$ok=1;

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

{

echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";

}

else

{

echo "Sorry, there was a problem uploading your file.";

}

$uploaded_size = $_FILES['uploaded']['size'];

if ($uploaded_size > 350000)

{

echo "Your file is too large.
";

$ok=0;

}

$currentdate = date('Y-M-D h:i:s');

$filename = $_FILES['uploaded']['name'];

$id = '2';

you can save these uplaoad image in which database you need and can display

?>

//fetch the image from database and assign to smarty variable $getimage

src="{$getimage}" style="width:125px; float:left; height:175px; margin-left:9%;margin-bottom:5px; background:#f2f2f2; border:1px solid #cccccc">  

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you upload and resize an image with PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

How do you install PHP scripts?

You need to upload the scripts to web hosting space that support PHP.


How would one resize a picture?

The most popular way to resize a picture is to put it into a digital format on your computer, and than manually resize it using software such as Photoshop or MS Paint. Some websites also offer a resize service for completely free.


How do you upload function in php?

If you mean uploading files...HTML Form (front-end):Filename:PHP (upload_file.php)Thank You Google & w3schools (http://www.w3schools.com/php/php_file_upload.asp)


What is new in PHP?

PHP is a recursive acronym for "PHP: Hypertext Preprocessor" created by The PHP Group. PHP is a widely used server-side scripting language and the general purpose of PHP is to create dynamic Web Pages. For more information, visit the PHP website.


How can we upload in php?

this is file of index.php or any file that contains uploading area ....... .................................................................................... <body> <form name="frmFile" method="post" action="fileuploadprocess.php" enctype="multipart/form-data"> <label>Select File</label> <input type="file" name="flnFile" /> <br /> <input type="submit" value="Upload File" /> </form> </body> ..................................................................................................... fileuploadprocess.php that is in form action="fileuploadprocess.php" <?php //print_r($_FILES); //echo(phpinfo()); $sType=$_FILES['flnFile']['type']; echo($sType); //echo("<br>"); $arrFileTypes=array("image/jpeg","image/png","image/gif"); $iFileSize=$_FILES['flnFile']['size']; // For KBs $iFileSize=$iFileSize/1024; // For MBs //$iFileSize=$iFileSize/1024; echo($iFileSize); echo("<br>"); //if($sType=="image/jpeg" $sType=="image/png" //$sType=="image/gif") if($iFileSize<=100) { if(in_array($sType,$arrFileTypes)) { $sDirectory="Uploadfiles/sajid"; if(is_dir($sDirectory)) { } else { mkdir($sDirectory,0777); } $dDateTime=date('mdyhis'); $sTempLocation=$_FILES['flnFile']['tmp_name']; //$sDesignationLocation="Uploadfiles/".$dDateTime.$_FILES['flnFile']['name']; $sDesignationLocation=$sDirectory."/".$dDateTime.$_FILES['flnFile']['name']; //echo($sDesignationLocation); move_uploaded_file($sTempLocation,$sDesignationLocation); } else { echo("File type error"); } } else { echo("File size Error"); } ?>

Related questions

How do you upload an image to MySQL using PHP?

You cant upload an actual picture to MySQL, you can upload the URL but not the picture itself. You would have to upload this to your site first and then send the link to MySQL


How do you upload an image using PHP?

You upload the image in HTML using a form that includes the following field <input type="file" name="fileUpload" /> After the form is submitted, you can access it with the $_POST variable as $_POST['fileUpload'] http://www.tutorialsscripts.com/free-php-scripts/file-and-directory-script/image-upload.php


Why php not able to fetch the image from 'My Picture' in win XP to Script and diplay it?

PHP is a server-side language, and doesn't have access to your hard-drive. You have to get the user to upload the picture to the server, first.


How can I change my Photos Background and resize photo?

How can I change my Photos Background and resize photo? Answer: Use Lunapic to resize, enlarge, shrink or scale an image instantly. Use the form above to choose a image file or URL. After uploading, choose the width or height of the image. You can also drag the corners of the image to resize it. In the future, use the menu above Edit -> Resize Image.


How do you install PHP scripts?

You need to upload the scripts to web hosting space that support PHP.


What is php image size?

PHP can create images of different sizes. It depends on a particular image.


How do you get PHP codes for writing on an image?

You can use the GD extension for PHP to edit image files.


How do you resize photo for printing?

As usual, Image > Image Size but pay attention on image resolution.


How do you make a document in PHP about image manipulation?

I have had a lot of experience with image modification modules with PHP. In order to perform image manipulation in PHP you need an image processing module installed such as GD2 or imagemagik. GD2 comes with PHP and can be installed fairly easily if it is not already installed. You can follow the PHP GD manually for the usage of these functions.


What is interpolation in image processing?

you resize or remap your image from one pixel grid to another.


Can you sen a code to upload photo in javascript or php?

Please go to www.google.com, and search for "php upload photo script" or something alike. I'm sure you'll find somthing there.


How do you re size pictures?

Image > Resize Enter size.