Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $listingId = $_GET['listing_id'];
- if(isset($_POST['submit']))
- {
- $target_dir = "./images/listing_images/";
- $target_file = $target_dir . basename($_FILES["file_selected"]["name"]);
- //temp varriables for file details
- $file_name = $_FILES["file_selected"]["name"];
- $file_type = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
- $file_size = $_FILES["file_selected"]["size"];
- $is_valid = 1;
- if($file_type != "jpg")
- {
- $is_valid = 0;
- echo "File must be a jpg!";
- }
- if($file_size > MAX_FILE_SIZE)
- {
- $is_valid = 0;
- echo "File cannot be larger than " + MAX_FILE_SIZE;
- }
- if ($is_valid == 1)
- {
- move_uploaded_file($_FILES["file_selected"]["tmp_name"], $target_file);
- echo "Success!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement