bool move_uploaded_file ( string $filename , string $destination )
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP’s HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
<?php if($_FILES['file']){ move_uploaded_file($_FILES['file']['tmp_name'], './img/test.jpg'); } ?> <form action="./index.php" method="POST" enctype="multipart/form-data"> <input type="file" name="faile"> <input type="submit" value="ファイルをアップロードする"> </form>
php error
<?php try{ if(is_uploaded_file($_FILES['file']['tmp_name'])){ move_uploaded_file($_FILES['file']['tmp_name'], './img/test.jpg'); } } catch(Exception $e){ echo 'エラー:', $e->getMessage().PHP_EOL; } ?> <form action="./index.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file"> <input type="submit" value="ファイルをアップロードする"> </form>
php form
php.init
file_uploads, post_max_size, upload_max_filesize, memory_limit, max_execution_time, upload_tmp_dir, max_file_uploads
Tells whether the file was uploaded via HTTP POST