0
votes

I trying to create an apache2 webpage that allows user upload nifti(.nii, .nii.gz) files.

I tried two different ways:

  1. On WSL Ubuntu 18.04, "move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)" returns nothing. Its totally fails.

  2. On XAMPP, the page can take files such as PDF, JPG ..etc, but not .nii, .exe (I checked $_FILES['file']['tmp_name']; is empty)

HTML:

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select file to upload: 
    <input type="file" name="file"> 
    <input class="" type="submit" value="Upload" name="submit">
</form>

php:

   $target_dir = "/home/user/public_html/uploads/";
   $target_file = $target_dir . basename($_FILES["file"]["name"]);
   $uploadOk = 1;
   $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
   $file_tmp =$_FILES['file']['tmp_name'];
   if ($uploadOk == 0) {
     echo "Sorry, your file was not uploaded.";
     echo "<br>";
   } else {
   $moving = move_uploaded_file($file_tmp, $target_file);
   echo $moving;
   echo "here <br>";
   if ($moving) {
     echo "The file ". basename( $_FILES["file"]["name"]). " has been 
 uploaded.";
   } else {
     echo "Sorry, there was an error uploading your file.";
   }
   }
  1. Did someone uploaded file successfully on a WSL apache2?
  2. Why I can't upload files like ".nii", ".nii.gz", ".exe"?

Thank you for reading!

1

1 Answers

0
votes

Ok, After a few hours trying, I find out why I cannot upload ".nii", ".nii.gz". but I got new questions.

Even if I have already set:

upload_max_filesize = 100M
Post_max_size = 500M

The page still cannot take file greater than 8M, I saw that on the php error.log.

The .gz file is smaller than 8M, but the extracted file is greater than 8M, so it cannot upload.

Does someone know why my "php.ini" setting is not working?