Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to deny identical images being uploaded with PHP
    primarykey
    data
    text
    <p>I want to create a way to search a directory by Imagetype or similiar variable.. before the image is uploaded to that diretory. </p> <p>My goal is to search the BLOB of images in that directory with php, and if any result match (meaning there will duplicate uploads of the same image) return with "File already uploaded". </p> <p>This will only pertain to image files...</p> <p>Here is the code I think I can add too..</p> <pre><code>// Elements (values) of $_FILES['ImageFile'] array //let's access these values by using their index position $ImageName = str_replace(' ','-',strtolower($_FILES['ImageFile']['name'])); $ImageSize = $_FILES['ImageFile']['size']; // Obtain original image size $TempSrc = $_FILES['ImageFile']['tmp_name']; // Tmp name of image file stored in PHP tmp folder $ImageType = $_FILES['ImageFile']['type']; //Obtain file type, returns "image/png", image/jpeg, text/plain etc. //Let's use $ImageType variable to check wheather uploaded file is supported. //We use PHP SWITCH statement to check valid image format, PHP SWITCH is similar to IF/ELSE statements //suitable if we want to compare the a variable with many different values switch(strtolower($ImageType)) { case 'image/png': $CreatedImage = imagecreatefrompng($_FILES['ImageFile']['tmp_name']); break; case 'image/gif': $CreatedImage = imagecreatefromgif($_FILES['ImageFile']['tmp_name']); break; case 'image/jpeg': case 'image/pjpeg': $CreatedImage = imagecreatefromjpeg($_FILES['ImageFile']['tmp_name']); break; default: die('Unsupported File, Please Check File And Try Again!'); //output error and exit } </code></pre>
    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.
 

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