Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload image with thumbnail and original picture
    primarykey
    data
    text
    <p>I've been using this script to upload pictures on my website for a year now and I finally realised that changes has to be done. I've been looking all over the internet but have not yet found any proper solution, so I've come to you.</p> <ul> <li><em>This script is currently creating and moving a thumb image into the folder '/images' with the propereties 111x111.</em></li> <li><p><em>I want it to also upload the original picture, how do I do that?</em></p> <pre><code>if(isset($_POST['submit'])) { if (($_FILES["image"]["type"] == "image/jpeg" || $_FILES["image"]["type"] == "image/pjpeg" || $_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/x-png") &amp;&amp; ($_FILES["image"]["size"] &lt; 4000000)) $current_img=$_FILES['image']['name']; $extension = substr(strrchr($current_img, '.'), 1); date_default_timezone_set("Europe/Stockholm"); $time = date("fYhis"); $new_image = uniqid() . $time; $destination = "images/".$new_image . "-thumb" . "." . $extension; $action = move_uploaded_file($_FILES['image']['tmp_name'], $destination); $max_upload_width = 111; $max_upload_height = 111; if($_FILES["image"]["type"] == "image/jpeg" || $_FILES["image"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($destination) ; } if($_FILES["image"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image"]["tmp_name"]); } if($_FILES["image"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image"]["tmp_name"]); } if($_FILES["image"]["type"] == "image/x-png"){ $image_source = imagecreatefrompng($_FILES["image"]["tmp_name"]); } imagejpeg($image_source,$destination,100); chmod($destination,0644); list($image_width, $image_height) = getimagesize($destination); if($image_width&gt;$max_upload_width || $image_height &gt;$max_upload_height){ $proportions = 1; if($image_width&gt;$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($destination); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image, $destination, 100); // save imagedestroy($new_image); } </code></pre></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload