fife Posted December 22, 2011 Share Posted December 22, 2011 OK. I have tried to make my own image upload script which checks if the image is bigger the 500px in height. If it is shrinks the image down then uploads it an saves it to a database. I got the upload an save to database working fine. Once I added the check size bits it just fails with no error. Does anybody know of any simple scripts or tuts out there that do this as Im fed up of banging my head against the wall. Ive tried to find one myself but they dont exist it would seem!! heres my code anyway just incase its fixable.. I get no error an no redirect, I dont think its even making it to the move upload file as its not appearing on my server <?php if(isset($_POST['submit'])){ $fileName9 = trim($_FILES['imagefile']['name']); $tmpName = $_FILES['imagefile']['tmp_name']; $fileType = $_FILES['imagefile']['type']; //re name the image $randName = md5(rand() * time()); $fileName = $randName.$fileName9; //where to save the image $folder = "{$_SERVER['DOCUMENT_ROOT']}/members/images/{$members['county']}/"; //check types $types = array('image/jpeg', 'image/gif', 'image/png', 'image/JPG', 'image/pjpeg', 'image/x-png'); if (in_array($fileType, $types)) { //get original width and height $size = @GetImageSize($fileName); $width = $size[0]; $height = $size[1]; // auto adjust width of image according to predetermined height $new_height = 500; $new_width = $width * ($new_height/$height); // Resample image $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $fileName, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // New image $image = $image_resized; } // Your file handing script here if(move_uploaded_file($tmpName , $folder.$image)) { $qInsert = mysql_query("UPDATE `members` SET profilePic = '$image' WHERE userID = '".$members['userID']."'") or die (mysql_error()); } if ($qInsert){ $url = "/members/clubs/image.php?pic=$image"; header("Location: $url"); } } ?> <form action="" method="post" enctype="multipart/form-data" name="photo" id="photo"> <input name="imagefile" type="file"> <input name="submit" type="submit" id="submit"> </form> Quote Link to comment Share on other sites More sharing options...
fife Posted December 22, 2011 Author Share Posted December 22, 2011 ops wrong board Quote Link to comment Share on other sites More sharing options...
fife Posted December 22, 2011 Author Share Posted December 22, 2011 please ignore or answer on the correct board called coding help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.