PHP错误 - 上传文件 [英] PHP Error - Uploading a file

查看:140
本文介绍了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:\inetpub \vhosts \ mywebsite.com \\中的权限被拒绝第3行\\ httpdocs\dump \ upload.php

Warning: move_uploaded_file(./test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 3

警告:move_uploaded_file()[function.move-uploaded-file]:无法移动'C:\\第3行的E:\inetpub \vhosts \ mywebsite.com \httpdocs \dump\upload.php中的\\ WINDOWS \Temp \\\ php.30.tmp'到'./test.txt'

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpA30E.tmp' to './test.txt' in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 3

警告:无法修改标头信息 - 已经发送的标头(输出从E:\inetpub \vhosts \ mywebsite.com \httpdocs \dump\upload开始。 php:3)在E:\inetpub\vhosts \ mywebsite.com \httpdocs\dump\upload.php第4行

Warning: Cannot modify header information - headers already sent by (output started at E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php:3) in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.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:\inetpub\vhosts\mywebsite.com\httpdocs\dump\
C:\WINDOWS\Temp\

这篇关于PHP错误 - 上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆