Jump to content

mousmoulis

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mousmoulis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My files are stored locally and using my browser i want to upload images to the webserver. the code is as follows but I don't think it has to do with the code The echos are in Greek and are only messages appearing to the user to know if he has completed his task successfully or not. [table][tr][td]if ($_FILES['appScreenshot']['name']) { $uploaddir = "../images/screenshots/"; $allowed = array('image/gif','image/jpeg','image/png'); $verified_ext = false; $extension = pathinfo($_FILES['appScreenshot']['name']); $extension = $extension['extension']; echo $_FILES['appScreenshot']['size']; if(in_array($_FILES['appScreenshot']['type'], $allowed)) { $verified_ext = true; } else { echo "Η επέκταση του αρχείου της εικόνας δεν είναι έγκυρη. Πρέπει να είναι jpg, gif, png, jpeg"; exit(); } if($appScreenshot!="") { if(is_dir($uploaddir)) { if(!unlink($uploaddir.$appScreenshot)) { echo "Δεν είναι δυνατή η διαγραφή της υφιστάμενης εικόνας. Ξαναπροσπαθήστε."; exit(); } } else { echo "Η εικόνα δεν είναι καταχωρισμένη σε έγκυρη διαδρομή στο server"; exit(); } } $screenshot = $appID.".".$extension; $final_upload_file = $uploaddir.$screenshot; if($verified_ext == true) { if($_FILES['appScreenshot']['size'] > $max_size) { echo "Το μέγεθος της εικόνας είναι πολύ μεγάλο. Εισάγετε εικόνα με μικρότερο μέγεθος."; exit(); } if($_FILES['appScreenshot']['size'] == 0) { echo "Η εικόνα έχει μηδενικό μέγεθος. Εισάγετε εικόνα με μεγαλύτερο μέγεθος."; exit(); } if(is_uploaded_file($_FILES['appScreenshot']['tmp_name'])) { if(is_dir($uploaddir)) { if(!file_exists($final_upload_file)) { if(!move_uploaded_file($_FILES['appScreenshot']['tmp_name'],$final_upload_file)) { echo "Δεν ήταν δυνατή η αποστολή του αρχείου εικόνας στο sever"; exit(); } } else { echo "Υπάρχει ήδη αρχείο καταχωρισμένο για την τρέχουσα εφαρμογή"; exit(); } } else { echo "Η διαδρομή αποθήκευσης της εικόνας δεν είναι έγκυρη"; exit(); } } [/table]
  2. I have made a page through which I upload images to the webserver. Jpeg, gif, png are only accepted. 90% of them are uploaded successfully. But there is a problem with the other 10%. What is happening is that for some reason while in the 90% of the images my page can recognize the size and the type of the image in the other 10% it can't. When I echo the $_FILES['image']['type'], $_FILES['image']['size'] I get nothing and zero respectively. So when I check whether the file is jpeg, png or gif I get the message that the file is not in the right format. But even if I comment out the checking about the file size or type although it looks as if the file was uploaded the file isnot present in the server. It is as if the images aren't thought to be valid files although in my PC they are recognised as e.g. png file with size = 121kb. I have even tried to convert the images to different format or size but the result remains the same. Does anybody knows why some images are recognised and other are not?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.