Russia Posted November 20, 2014 Share Posted November 20, 2014 I am working on an uploader and slowly getting it working, I am uploading 3 images at once, and setting arrays for each one as keys, with an increment of ++1. I am wanting to resize the image before it gets copied to the thumbnail folder.I have this code. <?php if (isset($_POST['addpart'])) { $image = $_FILES['images']['tmp_name']; $name = $_POST['username']; $i = 0; foreach ($image as $key) { $fileData = pathinfo(basename($_FILES["images"]["name"][$i])); $fileName[] = $name . '_' . uniqid() . '.' . $fileData['extension']; move_uploaded_file($key, "image/" . end($fileName)); //get uploaded file info before we proceed with resize $image_name = $_FILES['images']['name'][$i]; //file name $image_size = $_FILES['images']['size'][$i]; //file size $image_temp = $_FILES['images']['tmp_name'][$i]; //file temp $image_size_info = getimagesize($image_temp); //gets image size info from valid image file copy("image/" . end($fileName), "image_thumbnail/" . end($fileName)); $i++; } echo 'Uploaded<br>'; echo 'Main Image - ' . $fileName[0] . '<br>'; echo 'Extra Image 1 - ' . $fileName[1] . '<br>'; echo 'Extra Image 2 - ' . $fileName[2] . '<br>'; echo '<hr>'; } ?> Everything works with it. As you see, I started on getting the file info, but after that I am totally stuck on what to do after to resize the image proportionally with a maximum width of xPX and height to match it without looking distorted.Any help would be really appreciated. Thank You. Link to comment https://forums.phpfreaks.com/topic/292581-resize-copied-image-on-upload-as-thumbnail/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.