$upload_img->upload_dir = 'images/'; // "files" is the folder for the uploaded files (you have to create this folder) $upload_img->extensions = array(".jpg"); // specify the allowed extensions here $upload_img->max_length_filename = 1000; // change this value to fit your field length in your database (standard 100) $upload_img->rename_file = true; $upload_img->the_temp_file = $_FILES[$file]['tmp_name']; $upload_img->the_file = $_FILES[$file]['name']; $upload_img->http_error = $_FILES[$file]['error']; if ($upload_img->upload()) { // new name is an additional filename information, use this to rename the uploaded file $full_path = $upload_img->upload_dir . $upload_img->file_copy; $imagename = $upload_img->get_uploaded_file_info($full_path); } } else { $imagename = ""; } return $imagename; } } $upload = new file_upload(); if ($_FILES['image']['size'] == 0) { header("location: image-cropping.php?er=1"); } else { $image_name = $upload->image_upload('image'); } session_start(); $_SESSION['SUID'] = date("Ymdhi"); $_SESSION['SIMG'] = $image_name; header("location: image-cropping.php");