PHP 错误 - 上传文件
我正在尝试编写一些 PHP 来将文件上传到我的网络服务器上的文件夹.这是我所拥有的:
I'm trying to write some PHP to upload a file to a folder on my webserver. Here's what I have:
<?php
if ( !empty($_FILES['file']['tmp_name']) ) {
move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']);
header('Location: http://www.mywebsite.com/dump/');
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Dump Upload</title>
</head>
<body>
<h1>Upload a File</h1>
<form action="upload.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
Select the File:<br /><input type="file" name="file" /><br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
我收到以下错误:
警告:move_uploaded_file(./test.txt) [function.move-uploaded-file]:无法打开流:E:inetpubvhostsmywebsite.comhttpdocsdumpupload.php 中的权限被拒绝第 3 行
Warning: move_uploaded_file(./test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in E:inetpubvhostsmywebsite.comhttpdocsdumpupload.php on line 3
警告:move_uploaded_file() [function.move-uploaded-file]:无法将 'C:WINDOWSTempphpA30E.tmp' 移动到 E:inetpubvhostsmywebsite 中的 './test.txt'.comhttpdocsdumpupload.php 在第 3 行
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:WINDOWSTempphpA30E.tmp' to './test.txt' in E:inetpubvhostsmywebsite.comhttpdocsdumpupload.php on line 3
警告:无法修改标头信息 - 标头已由 E:inetpubvhostsmywebsite.com 中的(输出开始于 E:inetpubvhostsmywebsite.comhttpdocsdumpupload.php:3)发送httpdocsdumpupload.php 在第 4 行
Warning: Cannot modify header information - headers already sent by (output started at E:inetpubvhostsmywebsite.comhttpdocsdumpupload.php:3) in E:inetpubvhostsmywebsite.comhttpdocsdumpupload.php on line 4
PHP 版本 4.4.7在 Windows 机器上运行 IIS.这个特定的文件/文件夹有 777 个权限.
PHP version 4.4.7 Running IIS on a Windows box. This particular file/folder has 777 permissions.
有什么想法吗?
推荐答案
因为是Windows,所以没有真正的777.如果你使用的是chmod,查看Windows相关的注释.
As it's Windows, there is no real 777. If you're using chmod, check the Windows-related comments.
检查 IIS 帐户是否可以访问(读取、写入、修改)这两个文件夹:
Check that the IIS Account can access (read, write, modify) these two folders:
E:inetpubvhostsmywebsite.comhttpdocsdump
C:WINDOWSTemp
相关文章