POST method not working on the same page

0

When trying to upload a file from the error

<form method="POST">
<input type="file" name="inputfileSendTorrent">
<input type="submit" name="submitSendTorrent">
</form>
<?php
if(isset($_POST['submitSendTorrent']))
{   
    $uploaddir = '/arquivos/';
$arqName = $_FILES['inputfileSendTorrent']['name'];
$arqSize = $_FILES['inputfileSendTorrent']['size'];
$arqTemp = $_FILES['inputfileSendTorrent']['tmp_name'];
$upload = move_uploaded_file($arqTemp, $uploaddir . $arqName);
}
?>

Returns the error

Notice: Undefined index: inputfileSendTorrent in C:\xampp\htdocs\LuckTor2\pages\teste.php on line 9

Notice: Undefined index: inputfileSendTorrent in C:\xampp\htdocs\LuckTor2\pages\teste.php on line 10

Notice: Undefined index: inputfileSendTorrent in C:\xampp\htdocs\LuckTor2\pages\teste.php on line 11
    
asked by anonymous 13.02.2017 / 23:29

1 answer

0

Put the enctype="multipart/form-data" attribute in the form tag, which is required when the file is uploaded.

<form enctype="multipart/form-data" method="POST">
    
14.02.2017 / 00:05