It's my first time here and I wonder if you could understand my question for I am not from an English-speaking country.
I want to write some code to upload a file, my code is quite easy to understand if you are know PHP or JS. Here is my code.
<form action='data.php' method='post' enctype='multipart/form-data'>
<input type='file' name='file' />
<input type='submit' />
</form>
$user_uid = rand(0, 50000);
$file_pos = strpos($_FILES['file']['type'], '/');
$file_name = $user_uid . '.' . substr($_FILES['file']['type'], $file_pos + 1);
$savePath = dirname(__FILE__) . '\\' . $file_name;
copy($_FILES['file']['tmp_name'], $savePath);
As above, I want to get the tmp_name
of a file, but it does not work if a zip file or 7z file is uploaded. But it seems to work quite well for jpg or others, why?
I tried to output the $_FILES['file'] of a 7z, example below:
Object {name: "2.zip", type: "", tmp_name: "", error: 1, size: 0}
I find the tmp_name is "" so does its type if 7z, how does that happen? And if I want to upload a zip or 7z, how should I change my code?
@2017.09.13
increase that in php.ini and restart the server
upload_max_filesize = 180M
max_file_uploads = 180
upload_max_filesize = 180M