4
I’m using the following code :
$uploaddir = '../vagas/';
$uploadfile = $uploaddir . basename($_FILES['img']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Arquivo válido e enviado com sucesso.\n";
} else {
echo "Possível ataque de upload de arquivo!\n";
}
echo 'Aqui está mais informações de debug:';
print_r($_FILES);
print "</pre>";
The HTML is like this
<input type="file" name="img" id="img">
The error you present is Possible file upload attack! Here is more debug information:Array ( [img] => Array ( [name] => download.jpeg [type] => image/jpeg [tmp_name] => /Applications/XAMPP/xamppfiles/temp/phpOPe968 [error] => 0 [size] => 5555 )
)
But it is not uploading, already gave chmos in the folder of the server but still... How can I fix it? And if possible how could I rename the file ? Thank you
If you don’t have multi-part in the form it doesn’t send the file.
– rray
ok put but memo like this nothing
– Augusto Furlan
In the
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)
shouldn’t be sending$_FILES['img']['tmp_name']
instead of$_FILES['userfile']['tmp_name']
?– Thyago ThySofT
as Thyago did not understand the suggested amendment
– Augusto Furlan
you need to use the same as in the form, no
$_FILES
, in the form isimg
and in the$_FILES
isuserfile
, use @+usuario to notify him.– rray
Yes, I have, but to no avail....
– Augusto Furlan
Well, within what you’ve given us so far, I’ve posted an answer for better visualization of the code.
– Thyago ThySofT