Image Deleted
"; }else{ echo "Image Delete Error
"; } } } //validate file ext function getExtension($str) { $i = strrpos($str,'.'); if (!$i) { return ''; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //create thumbs function function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( @strtolower($info['extension']) == 'jpg' or @strtolower($info['extension']) == 'jpeg' or @strtolower($info['extension']) == 'jpe') { // echo "Created thumbnail for - {$fname}
"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } } // close the directory closedir( $dir ); } $submited=''; if($allowUpload) { if(isset($_POST['submit2']) && !empty($_POST['submit2'])) { $submited='yes'; $path = $dirpath; //Folder where uploaded files go if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { if ((($_FILES["userfile"]["type"] == "image/gif") || ($_FILES["userfile"]["type"] == "image/jpg") || ($_FILES["userfile"]["type"] == "image/jpe") || ($_FILES["userfile"]["type"] == "image/gif") || ($_FILES["userfile"]["type"] == "image/jpeg")) && ($_FILES["userfile"]["size"] < $maxsize)) { $filename = stripslashes($_FILES['userfile']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests //echo $extension; if ($extension == "jpg" or $extension == "jpeg" or $extension == "gif") { $pass="1"; }else{ //print error message echo '

Unknown or unallowed file type!

'; exit; } if (file_exists($path . $_FILES['userfile']['name'])) { echo 'A File With That Name Already Exists!
'; exit; } $filename = $_FILES['userfile']['name']; $filename = strtolower($filename); $filename=str_replace(" ","_", $filename); $newfilename =$path; $newfilename .=$filename; $res = copy($_FILES['userfile']['tmp_name'], $newfilename); if (!$res){ echo 'Upload Failed!
'; exit; } else{ //echo "Upload Successful!
"; if($createThumb){ if(!is_dir($dirpath."thumbnails/")){ mkdir($dirpath."thumbnails/", 755); } createThumbs($dirpath,$dirpath . 'thumbnails/',100); } echo 'Upload Successful!
'; }}}} }// end if allowUpload $thelist=''; $dirpath = substr($dirpath, 0, -1); // testing only // $cycle = true; // while ( $cycle !== false ) { // $file = readdir( $dh); // print ( "GOT a FILe or a FALSE:". $file ."
" ); // // do your stuff here // $cycle = $file; // } // // exit; // initialize variables first $handle = false; $files = ''; // assign the handler $handle = opendir($dirpath); $i="0"; // work only if necessary if ( $handle !== false ) { while ( ( $file = readdir( $handle ) ) !== false ) { if (!is_dir($dirpath .'/'.$file) and $file != "." && $file != ".." && $file != "Thumbs.db" ) { //gets image dimensions list($width, $height) = getimagesize($dirpath.'/'.$file); $i++; $thelist .="($i) $file
"; //can set for full size image pop up $thelist .=" View image"; $thelist .= " - DeleteAre you sure you want to delete this image
"; } } closedir($handle); } ?> cmxads image and file upload manager free cool php script "; echo ""; echo '
'; echo '
'; echo "Just drag image/name where you want it."; echo "

$thelist

"; echo '
'; //if(!$submited) //{ echo ""; echo "
Upload Image jpg,jpeg,jpe,gif only(Max $maxsize)
"; echo "
"; echo "Select File:"; echo " "; echo ""; echo "
"; echo "
"; //} echo "close window
"; echo '
'; echo ""; echo ""; ?>