false, 'message' => 'An unknown error occurred.' ]; if (isset($_FILES['fileUpload']) && $_FILES['fileUpload']['error'] === UPLOAD_ERR_OK) { $fileTmpPath = $_FILES['fileUpload']['tmp_name']; $fileName = $_FILES['fileUpload']['name']; $fileSize = $_FILES['fileUpload']['size']; $fileType = $_FILES['fileUpload']['type']; $fileNameCmps = explode(".", $fileName); $fileExtension = strtolower(end($fileNameCmps)); // Sanitize file name $newFileName = md5(time() . $fileName) . '.' . $fileExtension; $destPath = $uploadDir . $newFileName; // Check if file is allowed $allowedfileExtensions = ['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png']; if (in_array($fileExtension, $allowedfileExtensions)) { if(move_uploaded_file($fileTmpPath, $destPath)) { $response['success'] = true; // In a real app, you would save this info to the database $response['message'] = "File uploaded successfully!"; $response['data'] = [ 'original_name' => htmlspecialchars($fileName), 'new_name' => $newFileName, 'path' => $destPath, 'print_options' => [ 'location' => htmlspecialchars($_POST['location'] ?? 'N/A'), 'color' => htmlspecialchars($_POST['color'] ?? 'N/A'), 'sides' => htmlspecialchars($_POST['sides'] ?? 'N/A'), 'paper_size' => htmlspecialchars($_POST['paperSize'] ?? 'N/A'), 'orientation' => htmlspecialchars($_POST['orientation'] ?? 'N/A'), ] ]; } else { $response['message'] = 'There was some error moving the file to upload directory.'; } } else { $response['message'] = 'Upload failed. Allowed file types: ' . implode(', ', $allowedfileExtensions); } } else { $response['message'] = 'Error uploading file. Error code: ' . $_FILES['fileUpload']['error']; } // For demonstration, we'll just print the response. // In a real app, you might redirect with a status message. ?>
= htmlspecialchars($response['message']) ?>
File: = $response['data']['original_name'] ?>
Location: = $response['data']['print_options']['location'] ?>
Color: = $response['data']['print_options']['color'] ?>
Sides: = $response['data']['print_options']['sides'] ?>
Paper Size: = $response['data']['print_options']['paper_size'] ?>
Orientation: = $response['data']['print_options']['orientation'] ?>
Next step would be to calculate the bill and proceed to payment.