Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial ThinkPHP做的,部署在IIS上,上传图片报“上传目录不可写”

ThinkPHP做的,部署在IIS上,上传图片报“上传目录不可写”

Jun 23, 2016 pm 02:38 PM

1

public function upload() {        //导入图片上传类        import("ORG.Net.UploadFile");        //实例化上传类        $upload = new UploadFile();        $upload->maxSize = 3145728;        //设置文件上传类型        $upload->allowExts = array('jpg','gif','png','jpeg');        //设置文件上传位置        $upload->savePath = __ROOT__.'/Public/Uploads/Images/';        //设置文件上传名(按照时间)        $upload->saveRule = "time";        if (!$upload->upload()){            $this->error($upload->getErrorMsg());        }else{            //上传成功,获取上传信息            $info = $upload->getUploadFileInfo();        }        $savename = $info[0]['savename'];        $url = $savename;        //保存表单数据,包括上传的图片        $model = M("pkxs");        if (false === $model->create ()) {            $this->error ( $model->getError () );        }        // 更新数据        $list=$model->save ();        if (false !== $list) {            //成功提示            $this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );            $this->success ('编辑成功!');        } else {            //错误提示            $this->error ('编辑失败!');        }    }

Copy after login

代码中的目录是存在的,我在IIS中也将整个“Uploads”文件夹及子文件夹都赋了“写入”权限,为什么还是提示“上传目录/WEB/WPM/Public/Uploads/Images/不可写”呢?


回复讨论(解决方案)

你的上传目录是在网站中吗?
如果是,需要在 iis 管理其中勾选“写入”

从根起到你的上传目录,路径名中不能有中文
windows 的默认字符集是 gbk,而 TP 是 utf-8 的

对于非 iis 管理的文件夹仅有写入权限是不够的,还需在高级选项卡中勾选 允许存档

你的上传目录是在网站中吗?
如果是,需要在 iis 管理其中勾选“写入”

从根起到你的上传目录,路径名中不能有中文
windows 的默认字符集是 gbk,而 TP 是 utf-8 的

对于非 iis 管理的文件夹仅有写入权限是不够的,还需在高级选项卡中勾选 允许存档

请问版主,我要将我的整个项目目录勾选“写入”?还是只是将上传目录勾选“写入”呢?

关于中文路径是没有的。

iis 的配置都是针对整个网站的

我找到原因了,不是IIS配置的问题,是上传目录文件夹的Users的写入权限没给。

还是要多谢版主!结贴给分!

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

Hot Article

Hot tools Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

6 Extra Skills Every PHP Developer Should Have 6 Extra Skills Every PHP Developer Should Have Feb 28, 2025 am 10:52 AM

6 Extra Skills Every PHP Developer Should Have

Understand Arrays in PHP Understand Arrays in PHP Feb 28, 2025 am 10:53 AM

Understand Arrays in PHP

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

See all articles