dongxilan9351 2014-06-17 03:44
浏览 35
已采纳

通过get方法访问文件名时出错

i am using the get method to upload the file and when i write the $_FILES["file"]["name"]then it gives the error Undefined index: file but if i use the post method then it works fine. How can i access the file name or file type.Here is the code of first page.

<html>
<body>
<form action="upload2.php" method="GET"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

Here is the code of second page

 <?php
 $_FILES["file"]["name"];
 ?>
  • 写回答

2条回答 默认 最新

  • dongxia527680 2014-06-17 04:04
    关注

    Files cannot be uploaded through a GET request. You need to use POST.

    The PHP manual's definition for $_FILES:

    "An associative array of items uploaded to the current script via the HTTP POST method."

    (Emphasis mine)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?