10c04-1.php
来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 28 行
PHP
28 行
<?php// If we had any filesif (count($_FILES)) { // Doublecheck that we really had a file: if (!($_FILES['attachment']['size'])) { echo "<p>ERROR: No actual file uploaded</p>\n"; } else { // Determine the filename to which we want to save this file: $newname = dirname(__FILE__) . '/' . basename($_FILES['attachment']['name']); // Attempt to move the uploaded file to it's new home: if (!(move_uploaded_file($_FILES['attachment']['tmp_name'], $newname))) { echo "<p>ERROR: A problem occurred during file upload!</p>\n"; } else { // It worked! echo "<p>Done! The file has been saved as: {$newname}</p>\n"; } }}?><form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="f1"><input type="hidden" name="MAX_FILE_SIZE" value="8388608" /><p>Why don't you upload a file? <input type="file" name="attachment" /></p><p><input type="submit" /></p></form>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?