- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
根据 the POST method uploads section的 the PHP Manual , $_FILES['userfile']['name']
是客户端机器上文件的原始名称。该部分中的示例 #2 使用 basename
使用 $_FILES['userfile']['name']
的函数如下所示:
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
我在本地主机(Apache 2.2.14、PHP 5.3.1、Windows XP)上做了一些实验,发现以下两行是等价的:
$_FILES['userFile']['name']; // "file.txt"
basename($_FILES['userFile']['name']); // "file.txt"
也就是说,将 basename
函数与 $_FILES['userFile']['name']
一起使用似乎是多余的。不是吗?
最佳答案
That is, using the basename function with $_FILES['userFile']['name'] seems rather redundant. Isn't it?
不,正如@Gumbo 在他的回答中所描述的那样,首先是出于安全原因;其次,因为旧版本的 IE 过去常常在客户端提供文件的完整路径,比如
C:\Documents and Settings\Username\Desktop\Image_cropped.jpg
这种行为最近在 IE8 中停止了。来自 this MSDN blog entry通过 this SO question 发现:
File Upload control
Additionally, the “Include local directory path when uploading files” URLAction has been set to "Disable" for the Internet Zone. This change prevents leakage of potentially sensitive local file-system information to the Internet. For instance, rather than submitting the full path C:\users\ericlaw\documents\secret\image.png, Internet Explorer 8 will now submit only the filename image.png.
关于php - 将 basename 函数与 $_FILES ['userFile' ] ['name' ] 一起使用不是多余的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2347056/
我正在尝试上传多个图像,并且我设置了一个 jquery 插件,因此我可以浏览多个文件并选择它们。 我遇到的唯一问题是访问 Controller 中的文件数组,有人知道我该怎么做吗?谢谢。 看法: 最
我正在使用 Swift 3 和 Firebase 制作一个 iOS 应用。我不断收到错误消息“无法将‘UserFile’类型的值转换为预期参数‘User’”。这是我的代码: import Founda
我正在尝试在我的 Windows Forms 中创建一个文本文件应用。它工作正常,但它是在应用程序的默认位置(如文件夹 bin)创建文本文件。但我想将创建的文本文件保存在我的用户文件夹中。我该怎么做?
根据 the POST method uploads section的 the PHP Manual , $_FILES['userfile']['name'] 是客户端机器上文件的原始名称。该部分中
我正在我的 android 应用程序中使用本地化 当语言设置为阿拉伯语时,在 okhttp (okhttp:3.12.0) 的文件上传过程中出现此错误 E/AndroidRuntime: FATAL
我是一名优秀的程序员,十分优秀!