求大神帮看下这段代码 ,上传图片顺利,但是找不到图片

WBOY
Release: 2016-06-13 11:54:10
Original
1039 people have browsed it

求大神帮看下这段代码 ,上传图片成功,但是找不到图片?

<br /><!DOCTYPE html><br /><html><br />        <head><br />                <title>Test the input</title><br />        </head><br />        <body><br />                <form action="upload.php" method="post" enctype="multipart/form-data"><br />                        <label for="picture">PICTURE:</label><br /><br />                        <input type="file" name="picture" id="picture"/><br/><br />                        <input type="submit" name="submit" value="submit"/><br />                </form><br />        </body><br /></html><br />
Copy after login

<br /><?php<br />        $photo_dir='/var/www/images/';<br />        if(!is_dir($photo_dir)||is_writeable($photo_dir)){<br />                die('No dir exist or can write');<br />        }<br />        if($_FILES['picture']['error']>0){<br />                echo 'Error:'.$_FILES['picture']['error'].'<br/>';<br />        }<br />        else{<br />                echo "Upload:".$_FILES['picture']['name'].'<br />';<br />                echo "Type:".$_FILES['picture']['type'].'<br />';<br />                echo "Size:".($_FILES['picture']['size']/1024).'kb<br/>';<br />                echo "Stred in:".$_FILES['picture']['tmp_name'].'<br />';<br />                if(file_exists('/var/www/images/'.$_FILES['picture']['name']))<br />                {<br />                        echo $_FILES['picture']['name'].'already exists';<br />                }<br />                else<br />                {<br />                        $gpy=move_uploaded_file($_FILES['picture']['tmp_name'],'/var/www/images/'.$_FILES['picture']['name']);<br />                        if(gpy)<br />                        {<br />                                echo 'Succed';<br />                        }<br />                        echo 'Stored in:'.'images/'.$_FILES['picture']['name'];<br />                }<br />        }<br /><br />?><br /><br />
Copy after login

这段代码 竟然显示上传成功 ,但是我设置的文件路径中找不到上传的文件?
------解决方案--------------------
仔细检查下那个路径下确实没有上传的文件吗?

另外,打开错误提示功能,看上传过程中是否有报错信息。
------解决方案--------------------
你的 images 目录没有普通用户写权限
你可查看提交后的页面内容,肯定是没有 Succed 字样的
------解决方案--------------------

引用:
Quote: 引用:

Quote: 引用:

目录权限问题,images文件夹给www-data写权限了么

请问你指的权限是什么?我对/var/www/image 设置 对web也就是我 可读可写 这样对么?


web是你自己创建的用户,apache的用户名是www-data
------解决方案--------------------
if(gpy)  
明显错了。
应该是if(
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template