Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $target_dir = "uploads/";
- $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
- $uploadOk = 1;
- $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
- // Check if image file is a actual image or fake image
- if(isset($_POST["submit"])) {
- //$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
- $check = filesize($_FILES["fileToUpload"]["tmp_name"]);
- if($check !== false) {
- echo "This is a XLS format file - " . $check["mime"] . ".";
- $uploadOk = 1;
- } else {
- echo "This is not a XLS format file.";
- $uploadOk = 0;
- }
- }
- // Check if file already exists
- if (file_exists($target_file)) {
- echo "File already exists! Upload a new file";
- $uploadOk = 0;
- }
- // Check file size
- //check with WonHwa, what size limit are we looking at?
- if ($_FILES["fileToUpload"]["size"] > 500000) {
- echo "Sorry, your file is too large.";
- $uploadOk = 0;
- }
- // Allow certain file formats
- if($fileType != "xls" ) {
- echo "Sorry! Only XLS files can be uploaded!!";
- $uploadOk = 0;
- }
- // Check if $uploadOk is set to 0 by an error
- if ($uploadOk == 0) {
- echo "Sorry, your file was not uploaded.";
- // if everything is ok, try to upload file
- } else {
- if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
- // echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.".shell_exec("head -5 $target_file");
- // echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.".shell_exec("matlab -nodesktop -nosplash -r \"main_xls_input($target_file,40, 0.4, 0.01, 0.1, 3); exit\"");
- echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.".shell_exec("matlab -nodesktop -nosplash -r \"main_xls_input('".$target_file."',40, 0.4, 0.01, 0.1, 3); exit\"");
- } else {
- echo "Sorry, there was an error uploading your file.";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment