3
I’m trying to upload the file, but it doesn’t send to the folder. Shows the entire file sending process, receives in the database the new file name, but the file does not arrive in the server folder.
<?php
if ((isset($_POST["form"])) && ($_POST['form'] == "form1")) {
$ext = strtolower(substr($_FILES['arquivo']['name'],-4)); //Pegando extensão do arquivo
$arquivo = "file_".date('dmYhis') . $ext; //Definindo um novo nome para o arquivo
$dir = __DIR__.'/uploads/aulas/'; //Diretório para uploads
move_uploaded_file($_FILES['arquivo']['tmp_name'], $dir.$arquivo); //Fazer upload do arquivo
}
?>
<form id="form" method="post" autocomplete="off" enctype="multipart/form-data">
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label">Arquivo (.zip .rar .pdf)</label>
<input name="arquivo" type="file" id="file-1" required />
</div>
</div>
<button type="submit" id="button" name="button" class="btn btn-success pull-right"><i class="icon-save bigger-110"></i> Salvar</button>
</form>
UPDATE 1:
I ran the test on another server and it worked. I wonder what?
Update 2:
By placing a echo '<pre>';print_r($_FILES);echo '</pre>';
to see the exit, and it looks like this:
Array
(
[arquivo] => Array
(
[name] => artes-i---eja.pdf
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
)
Already checked the folder permissions?
– Woss
@Andersoncarloswoss Yes
– Tiago
Do me a favor. I know people don’t really like to do this in php but put your code inside
try
to see if you can extract some information.– Augusto Vasques
I never used the
try
, how should I do?– Tiago
https://www.php.net/manual/en/language.exceptions.php
– Augusto Vasques
@Augustovasques I did and returned no value.
– Tiago
@Augustovasques looks like it’s something on the server, something you’re blocking, because on the cPanel server it works on another server that uses another panel, it doesn’t work.
– Tiago
Now that I’ve seen
[error] => 1
, your file exceeded the size set in the directiveupload_max_filesize
within thephp.ini
– Augusto Vasques
@Augustovasques but in my php.ini file this with 12M
upload_max_filesize=12M
. This php.ini is in the root folderpublic_html/
, where the action is happening is inside the folderpublic_html/sistema/
, I need to put another php.ini inside the system folder?– Tiago
This is not the conventional way to
php.ini
.– Augusto Vasques
Hosting allows you to create custom php.ini
– Tiago
Custom does not mean that you recognize all fields. I believe it is an internal size limit of them, get in touch with the support and pass this information to them.
– Augusto Vasques
@Augustovasques misses exactly that. Give your answer to I put score for you. Thanks!
– Tiago
Thank you, just helping out, I’m glad. Now if you were grateful to enter my profile and read the answers I wrote and if any you find useful and want to score I will be flattered.
– Augusto Vasques