I have a small problem. I have a website where users can upload images but som .JPG images get uploaded but are not visible. The upload service accepts .jpg, .JPG, .jpeg ,.JPEG The size of the file is also under the maxium size that i allow.
I can se that the specific image i uploaded by looking in the upload folder on the server with FileZilla.
All other images are shown without any problems. Can the file that i try to upload may be damaged? Is there a way of check if the file is damaged/corrupt?
$file_name = $file['image']['name'];
$tmp_file = $file['image']['tmp_name'];
$extention = end(explode('.',$file_name));
if($extention == "png" || $extention == "jpg" || $extention == "jpeg" || $extention == "JPG" || $extention == "JPEG" || $extention == "svg"){
try{
$file_destination = '../files/'.$file_name;
//var_dump($file_destination);
if(move_uploaded_file($tmp_file,$file_destination)){
echo "
<div class='alert alert-success mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2'>
File uploaded successfully!
</div>
";
}else{
echo "
<div class='alert alert-danger mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2'>
Something went wrong;
</div>
";
}
}catch(PDOException $ex){
echo $ex->getMessage();
}
Thanks in advace!
Maybe you experienced trouble with chmod
.
Take a look on the file's permission after upload.