CI上传图片出现“You did not select a file to upload”错误的解决办法

本文详述了CodeIgniter(CI)框架下文件上传的常见问题与解决方案,包括文件域名称修改、form表单类型调整、nginx与php配置优化,以及文件上传路径权限问题的处理。

所有搜到的帖子都是:

1、文件域的名字被修改
方法一:
找了半天发现笔者将Views文件的文件域的名字修改成了fileimg,而CI默认的文件域的名字是userfile,即形如:。这个是不能修改的,否则就会找不到上传文件。
原理就是:$this->upload->do_upload()默认上传文件的表单名为userfile。
方法二:
其实还有解决方法,如果文件域是其他名字。比如:

将 $this->upload->do_upload();
改为 $this->upload->do_upload(‘imgfile’);
这样就可以了!
2、form表单类型
form表单需要使用form_open_multipart,形成HTML的时候会增加了一个属性enctype=“multipart/form-data”,这个其实是常识了,注意一下就好。

连文字都一模一样. 我试了! 不行

最后的解决还踩了三个坑才解决::

  1. nginx默认配置上传文件大小: 要在conf文件的server节加上这样一句:client_max_body_size 1024m;
  2. php的设置php.ini文件里也要改. 默认才2M和8M

设置文件最大上传限制(值的大小可以根据需求修改)
file_uploads = On ; 是否允许上传文件 On/Off 默认是On
upload_max_filesize = 32M ; 上传文件的最大限制
post_max_size = 32M ; 通过Post提交的最多数据
考虑网络传输快慢,这里修改一些参数
max_execution_time = 30000 ; 脚本最长的执行时间 单位为秒
max_input_time = 600 ; 接收提交的数据的时间限制 单位为秒
memory_limit = 1024M ; 最大的内存消耗
————————————————
版权声明:本文为优快云博主「一个菜鸟的前端之路」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/hl18730262380/article/details/83451159

  1. 最后还有一个坑 文件上传的路径! 可能没有权限, 因为nginx安装版用户是www-data. 没权限传不上去! 直接777.
SQL Queries. Copy all SQL queries into one sql file called part2.sql. For each query, please provide the comment as “part2a” for the first query. Upload your submissions as a single archive file called part2.zip. Consider the relational schema for company in Part I, write SQL queries for each request in Part I and one extra request in the following. Your queries should be executable in SQLite. In this part, you also need to use the "A2.db" (please download "A2.db" from course files) database in DB Browser for SQLite to give a screenshot for each query’s result. a. Print the names and ages of each employee who works in both the Hardware department and the Software department. (7 points) b. Print the name of each employee whose salary exceeds the budget of all the departments that he or she works in. To illustrate, if the employee works in 3 departments, whose budgets are 1000, 2000 and 3000 respectively, then the maximum budget of all the departments that he/she works in is 3000. (7 points) c. Find the ename, age of managers who manage only departments with budgets greater than $1 million. (7 points) d. Find the enames of managers who manage the departments with the greatest budgets. To illustrate, suppose there are three departments like this: department 1 with a budget of $1 million, department 2 with a budget of $2 million, department 3 with a budget of $2 million. Then departments 2 and 3 have the greatest budgets. (14 points) e. For each department with more than 20 full-time-equivalent employees (i.e., the total pct_time of the part-time and full-time employees add up to at least 2000 hrs, assuming that the pct_time of a full-time employee is 100 hrs), print the did together with the number of employees that work in that department. (10 points)
最新发布
11-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值