alconebay Posted April 5, 2008 Share Posted April 5, 2008 I have a form that uses the action below to upload and verify images (its works great) but I want to be able to be able to convert the images to jpg before they get sent to the upload directory. Would I insert something like "$oneofmyvariables->image_convert = 'jpg';" below? If so, where would I put it? I also want to make sure it's converted after that the rest of the script verifies that the original extension is an allowed extension. <?php if(isset($_POST['submit'])) { $allowed_extensions = array( 'png', 'bmp', 'jpg', 'jpeg', 'PNG', 'BMP', 'JPG', 'JPEG' ); $filename = $_FILES['file']['name']; $prefixed = $phone . "_" . $filename; $filesize = $_FILES['file']['size']; $fileerror = $_FILES['file']['error']; $filetmp = $_FILES['file']['tmp_name']; $new_filename = explode('.', $prefixed); if(in_array($new_filename[count($new_filename) -1], $allowed_extensions)) { $upload_path = "./image/" . $prefixed; if(!file_exists($upload_path)) { if($filesize < 1100000 && $filesize > 0) { if($fileerror) { echo "Error: " . $fileerror; } else { // Success! move_uploaded_file($filetmp, $upload_path); echo "Got it"; } } else { echo $filesize < 1 ? 'Too big...' : 'Too big...'; } }else { echo "Already exists"; } } else { echo "Unsupported image type"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/99733-need-some-help-with-image_convert/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.