当前位置:首页 » 文件管理 » onethink图片上传

onethink图片上传

发布时间: 2023-05-27 19:53:53

A. onethink,thinkphp 新手,想问一下POST传参和新加一个前台页面

index.php?s=/Home/Index/index.html
这个网址的意思是Home模块的Index控制器的index方法。

文件位置为 /Application/Home/Controller/IndexController.class.php
然后打开这个文件找到index方法

$_POST/$_GET 位置也是按照上面的方法的
假设你需要向 index.php?s=/Home/Index/myaction.html post一个衫物数据
需要在indexController.class.php文件里面添加一个方法 myaction,,然后在这个方法孙桐里面处理就可以了。

你可以看一下thinkphp的手则塌坦册里面都有介绍的

B. onethink的数据库配置文件在哪个路径下

一般分为windows和linux

windows通常放在安装目录下的 \Mysql\MySQL Server 5.0\my.ini

Linux 默认是放在 /etc/my.cnf

以下是my.cnf配置文件参数解释:
[client]
port = 3309
socket = /home/mysql/mysql/tmp/mysql.sock
[mysqld]
!include /home/mysql/mysql/etc/mysqld.cnf #包含的配置文件 ,把用户名,密码文件单独存放
port = 3309
socket = /home/mysql/mysql/tmp/mysql.sock
pid-file = /longxibendi/mysql/mysql/var/mysql.pid
basedir = /home/mysql/mysql/
datadir = /longxibendi/mysql/mysql/var/
# tmp dir settings
tmpdir = /home/mysql/mysql/tmp/
slave-load-tmpdir = /home/mysql/mysql/tmp/
#当slave 执行 load data infile 时用
#language = /home/mysql/mysql/share/mysql/english/
character-sets-dir = /home/mysql/mysql/share/mysql/charsets/
# skip options
skip-name-resolve #grant 时,必须使用ip不能使用主机名
skip-symbolic-links #不能使用连接文件
skip-external-locking #不使用系统锁定,要使用myisamchk,必须关闭服务器
skip-slave-start #启动mysql,不启动复制
#sysdate-is-now
# res settings
back_log = 50 #接受队列,对于没建立tcp连接的请求队列放入缓存中,队列大小为back_log,受限制与OS参数
max_connections = 1000 #最大并发连接数 ,增大该值需要相应增加允许打开的文件描述符数
max_connect_errors = 10000 #如果某个用户发起的连接error超过该数值,则该用户的下次连接将被阻塞,直到管理员执行flush hosts ; 命令;防止黑客
#open_files_limit = 10240
connect-timeout = 10 #连接超时之前的最大秒数,在Linux平台上,该超时也用作等待服务器首次回应的时间
wait-timeout = 28800 #等待关闭连接的时间
interactive-timeout = 28800 #关闭连接之前,允许interactive_timeout(取代了wait_timeout)秒的不活动时间。客户端的会话wait_timeout变量被设为会话interactive_timeout变量的值。
slave-net-timeout = 600 #从服务器也能够处理网络连接中断。但是,只有从服务器超过slave_net_timeout秒没有从主服务器收到数据才通知网络中断
net_read_timeout = 30 #从服务器读取信息的超时
net_write_timeout = 60 #从服务器写入信息的超时
net_retry_count = 10 #如果某个通信端口的读操作中断了,在放弃前重试多次
net_buffer_length = 16384 #包消息缓冲区初始化为net_buffer_length字节,但需要时可以增长到max_allowed_packet字节
max_allowed_packet = 64M #
#table_cache = 512 #所有线程打开的表的数目。增大该值可以增加mysqld需要的文件描述符的数量
thread_stack = 192K #每个线程的堆栈大小
thread_cache_size = 20 #线程缓存
thread_concurrency = 8 #同时运行的线程的数据 此处最好为CPU个数两倍。本机配置为CPU的个数
# qcache settings
query_cache_size = 256M #查询缓存大小
query_cache_limit = 2M #不缓存查询大于该值的结果
query_cache_min_res_unit = 2K #查询缓存分配的最小块大小
# default settings
# time zone
default-time-zone = system #服务器时区
character-set-server = utf8 #server级别字符集
default-storage-engine = InnoDB #默认存储
# tmp & heap
tmp_table_size = 512M #临时表大小,如果超过该值,则结果放到磁盘中
max_heap_table_size = 512M #该变量设置MEMORY (HEAP)表可以增长到的最大空间大小
log-bin = mysql-bin #这些路径相对于datadir
log-bin-index = mysql-bin.index
relayrelay-log = relay-log
relayrelay_log_index = relay-log.index
# warning & error log
log-warnings = 1
log-error = /home/mysql/mysql/log/mysql.err
log_output = FILE #参数log_output指定了慢查询输出的格式,默认为FILE,你可以将它设为TABLE,然后就可以查询mysql架构下的slow_log表了
# slow query log
slow_query_log = 1
long-query-time = 1 #慢查询时间 超过1秒则为慢查询
slow_query_log_file = /home/mysql/mysql/log/slow.log
#log-queries-not-using-indexes
#log-slow-slave-statements
general_log = 1
general_log_file = /home/mysql/mysql/log/mysql.log
max_binlog_size = 1G
max_relay_log_size = 1G
# if use auto-ex, set to 0
relay-log-purge = 1 #当不用中继日志时,删除他们。这个操作有SQL线程完成
# max binlog keeps days
expire_logs_days = 30 #超过30天的binlog删除
binlog_cache_size = 1M #session级别
# replication
replicate-wild-ignore-table = mysql.% #复制时忽略数据库及表
replicate-wild-ignore-table = test.% #复制时忽略数据库及表
# slave_skip_errors=all
key_buffer_size = 256M #myisam索引buffer,只有key没有data
sort_buffer_size = 2M #排序buffer大小;线程级别
read_buffer_size = 2M #以全表扫描(Sequential Scan)方式扫描数据的buffer大小 ;线程级别
join_buffer_size = 8M # join buffer 大小;线程级别
read_rnd_buffer_size = 8M #MyISAM以索引扫描(Random Scan)方式扫描数据的buffer大小 ;线程级别
bulk_insert_buffer_size = 64M #MyISAM 用在块插入优化中的树缓冲区的大小。注释:这是一个per thread的限制
myisam_sort_buffer_size = 64M #MyISAM 设置恢复表之时使用的缓冲区的尺寸,当在REPAIR TABLE或用CREATE INDEX创建索引或ALTER TABLE过程中排序 MyISAM索引分配的缓冲区
myisam_max_sort_file_size = 10G #MyISAM 如果临时文件会变得超过索引,不要使用快速排序索引方法来创建一个索引。注释:这个参数以字节的形式给出.重建MyISAM索引(在REPAIR TABLE、ALTER TABLE或LOAD DATA INFILE过程中)时,允许MySQL使用的临时文件的最大空间大小。如果文件的大小超过该值,则使用键值缓存创建索引,要慢得多。该值的单位为字节
myisam_repair_threads = 1 #如果该值大于1,在Repair by sorting过程中并行创建MyISAM表索引(每个索引在自己的线程内)
myisam_recover = 64K#允许的GROUP_CONCAT()函数结果的最大长度
transaction_isolation = REPEATABLE-READ
innodb_file_per_table
#innodb_status_file = 1
#innodb_open_files = 2048
innodb_additional_mem_pool_size = 100M #帧缓存的控制对象需要从此处申请缓存,所以该值与innodb_buffer_pool对应
innodb_buffer_pool_size = 2G #包括数据页、索引页、插入缓存、锁信息、自适应哈希所以、数据字典信息
innodb_data_home_dir = /longxibendi/mysql/mysql/var/
#innodb_data_file_path = ibdata1:1G:autoextend
innodb_data_file_path = ibdata1:500M;ibdata2:2210M:autoextend #表空间
innodb_file_io_threads = 4 #io线程数
innodb_thread_concurrency = 16 #InnoDB试着在InnoDB内保持操作系统线程的数量少于或等于这个参数给出的限制
innodb_flush_log_at_trx_commit = 1 #每次commit 日志缓存中的数据刷到磁盘中
innodb_log_buffer_size = 8M #事物日志缓存
innodb_log_file_size = 500M #事物日志大小
#innodb_log_file_size =100M
innodb_log_files_in_group = 2 #两组事物日志
innodb_log_group_home_dir = /longxibendi/mysql/mysql/var/#日志组
innodb_max_dirty_pages_pct = 90 #innodb主线程刷新缓存池中的数据,使脏数据比例小于90%
innodb_lock_wait_timeout = 50 #InnoDB事务在被回滚之前可以等待一个锁定的超时秒数。InnoDB在它自己的 锁定表中自动检测事务死锁并且回滚事务。InnoDB用LOCK TABLES语句注意到锁定设置。默认值是50秒
#innodb_flush_method = O_DSYNC
[mysqlmp]
quick
max_allowed_packet = 64M
[mysql]
disable-auto-rehash #允许通过TAB键提示
default-character-set = utf8
connect-timeout = 3

C. 六年级上册英语手抄报图片简单又漂亮

1. 英语手抄报图片简单又漂亮
英语手抄报图片简单又漂亮 英语手抄报又简单又好看单词不多
Park There is a park near my home.There are a lot of beautiful trees,flowers and birds in the park.So many people go to the park to enjoy their weekends.They like walking or having a piic in the park.But I like flying a kite with my sisiter there. 我家附近有一个公园.哪里有很多美丽的树、花和小鸟.所以很多人都喜欢到那里去度周末.他们喜欢在公园里散步或是野餐.但是我喜欢和我姐姐在那里放风筝. Bedroom I have a *** all bedroom.There are only a *** all bed,a *** all desk and a *** all chair in the room.And there is a beautiful doll on my blue bed.Everyday I do my homework,read books and play games with the doll in my bedroom.It is *** all,but it gives me much happiness. 我有一间小小的卧室.那里有一张小小的床、小小桌子和一把小小的椅子.而且还有一个漂亮的娃娃在我那张蓝色的小床上.我每天都在房间里写作业,看书和与我的娃娃玩.虽然房间很小,但是他给了我很多欢乐. My father My father is a tall and handsome man.He is a policeman. Everyday he es back home very late,because he must help the others.He doesn't have time to examine my homework and take me to the park.But I like my father,because he is a good policeman. 我的爸爸是一个高大帅气的男人.他是一个警察.他每天都很晚才回家,因为他要帮助其他的人带裤.他没有时间给我检查作业和带我去公园.但是我仍然很喜欢我的爸爸,因为他是一个好警察. A Fox, just at the time of the vintage, stole into a vine-yard where the ripe sunny Grapes were trellised up on high in most tempting show. He made many a spring and a jump after the luscious prize, but, failing in all his attempts, he muttered as he retreated:"Well what does it matter! The Grapes are sour!" 译文: 正当葡萄熟了的时候,一只狐狸偷偷地溜进了葡萄园.葡萄架上高高地挂着亮晶晶的、熟透了的葡萄,显禅旦得十分诱人.他跳了好几跳,蹦了好几蹦,想吃到这甘美的葡萄,但是他的企图全落空了,走开的时候,他自言自语说:"得了!这有什么!这葡萄是酸的." 词汇: trellised up 用棚架支撑着 in most tempting show 最诱人的样子 A mother's love never changes. 母爱永恒. An apple a day keeps the doctor away. 一天一苹果,不用请贺行扰医生. A new broom sweeps clean. 新官上任三把火. An eye for an eye and a tooth for a tooth. 以眼还眼,以牙还牙. An hour in the morning is worth two in the evening. 一日之计在于晨. An old dog cannot learn new tricks. 老狗学不出新把戏. An ounce of luck is better than a pound of wisdom. 聪明才智,不如运气. An ounce of prevention is worth a pound of cure. 预防为主,治疗为辅. A rolling stone gathers no moss. 滚石不生苔,转业不聚财. As a man sows, so he shall reap. 种瓜得瓜,种豆得豆. A single flower does not make a spring. 一花独放不是春,百花齐放春满园. A snow year, a rich year. 瑞雪兆丰年. A sound mind in a sound body.。
英语手抄报简单又好看春天诗句
Flowers bloom opened,sending out inviting scent,relaxed and happy making a person; Cute little swallow flew from the south,scenery,singing a song.Obviously,three on the steps of light has to hold us!Spring is a rebirth.When the spring rain drip-drip-drip down,like a pearl stood but the earth,wake up the first spring of bamboo shoots,wake up all the life,everything to wake up.Spring is a season of vitality.The arrival of the spring,make the world rejuvenated,restore the aura,restore the vitality.The birds freely in the blue sky to fly,and kept singing songs of joy,as if to wele the arrival of spring.Many plants in spring and grow,bloom,the dance。

Look,the tree out of the green branches; The grass yawn,senses; Bowing with the wind; Bud grin may toward everyone laugh,peach blossom and pear aromas refreshing.Spring is a season of roses.In spring,colorful flowers very charming,plus the bird clear moving singing,and the ubiquity of flowers,as in play a "spring symphony".The butterfly and the honey bee also touched and haste to join the flowers bloom,birds of the debates in the band,a good view of the poetic!"Every dance,play butterfly linger at oriole just cry j." Like fu verse,spring not only glows,or vivid!Let us together to feel the spring,enjoy the spring every a bunch of the warmth of sunshine and rain in the moist,cherish the good time of spring!Listen,ChunLei have rang through the air,"ChunLei a roar,the earth shake three shake." ChunLei is calling you put this beautiful spring describe it!翻译的内容如下:盛开的花朵开放,散发着诱人的香味,令人心旷神怡;可爱的小燕子从南方飞,风景,唱一首歌.很明显,三的步骤,光有抱着我们!春天是一个重生.当春雨drip-drip-drip下来,像珍珠站但地球,醒来的竹笋的第一个春天,一觉醒来所有的生命,一切都醒来.春天是生机盎然的季节.春季的到来,使世界重新焕发活力,恢复光环,恢复活力.鸟儿在蓝色的天空中自由地飞翔,并继续唱欢乐的歌,仿佛在欢迎春天的到来.许多植物在春天生长,开花,舞蹈…看,树上的绿枝上;草地上打哈欠,感觉;鞠躬风;芽咧嘴可能对每个人都笑了,桃花和梨花香气清新.春天是一个季节的玫瑰.在春季,五颜六色的花朵很迷人,加上鸟清晰动人的歌声,和无处不在的花,像在玩一个“交响乐之春”.蝴蝶和蜜蜂也感动和匆忙加入鲜花盛开,鸟儿的辩论在乐队,一个风景好的诗歌!“每一个舞蹈,玩蝴蝶黄鹂只是哭泣〉像杜甫诗句,春天不仅发光,或生动的!让我们一起去感受春天,享受春天的每一束温暖的阳光和雨露的滋润,珍惜春天的好时光!听着,春雷有响彻云霄,“春雷轰鸣,大地抖三抖.”春蕾叫你把这美丽的春天的描述!。

春节英语手抄报简单又好看happy.new year
Spring Festival Chinese New Year is the most important, interesting festival in China. Before the Chinese New Year, everyone is very busy. They want the Spring Festival to be a new beginning, so everyone is busy cleaning the room. They keep the room tidy. This is the first thing to wele the Spring Festival. The elderly take children to buy snacks and fireworks. But parents just stay at home to make tasty meals for dinner. On the evening of New Year's Eve, my parents and my sister have dinner with me. We have a good time. After dinner, Oh! Yeah! My father is ready to give us red pockets. Oh, how nice the red pockets are! My sister and I both all say, “Peace all year round to my parents! Now, give us red pockets.” My parents give us the red pockets at once with a *** ile on their faces. What a wonderful time we have! I think “Everything goes well” this year!译文: 春节 中国的新年是最重要的,有趣的节日在中国。

在春节之前,每个人都很忙。他们希望春节是一个新的开始,所以每个人都在忙着打扫房间。

他们保持房间整洁。这是为了迎接春节的第一件事。

老人带孩子去买零食和烟花。但父母呆在家里做美味的饭菜吃晚饭。

在除夕晚上,我的父母和我的妹妹和我一起吃晚饭。我们有一个很好的时间。

晚饭后,哦!是啊。我的父亲是准备给我们红色的口袋。

哦,多么漂亮的红包!我和妹妹都说,“四季平安给我父母!现在,让我们红色的口袋里。“我的父母给我们红包一次脸上带着微笑。

我们有一个多么美妙的时间! 我认为“一切顺利”今年!。
英语绘本手抄报简单又好看五年级下册
1 Bring Papa Teacher: For final exam this time, you can take your textbooks, your notebooks, your dictionary etc., just as you do your homework as usual. Frank: That sounds good. Then I can take my papa here. 【译文】带爸爸 老师:本次考试,你们可以带课本、笔记本、词典等,就像你们平常做作业一样。

弗里克:太好了,那我就可以把爸爸带来了。 2 Cat and crab One day, a cat played near the lake. Suddenly, a crab clamped it. The cat is rather cross , it ran after the crab. After a while, that cat ran into the forest. A big brown spider making its in the tree, the cat caught the big brown spider very fast, and the cat said to the big brown spider:" Did you think if you on the , I will not know you? Yes, I still know you?!" 【译文】猫和螃蟹 一天,一只猫在湖边玩耍。

忽然,一只螃蟹夹了它一下。那只猫非常生气,它追着那只螃蟹跑。

一会儿,它追到了森林里。一只大的棕色的蜘蛛正在树上织网,那只猫很快地抓住了那只大的棕色的蜘蛛,并对它说:“小样儿,你上了网我就不认识你了?!” Do you like autumn 你喜欢秋天么? I do not know when, you fall softly on my red sweater, you put a flower as I have it? 不知什么时候,你轻轻地落在我鲜红的毛衣上,你把我也当成一朵花了吗? Golden butterfly you! Whom you are dancing in it? Not *** ile flowers, grasses lost their luster. Oh, I see, you are in the garden that little daisy eyes. 金色的蝴蝶呀!你是在为谁而翩翩起舞呢?花儿没有了笑容,青草失去了光泽。

哦,我明白了,你是在为园子里那眨着眼睛的小雏菊。 Golden butterflies, you are willing to pay my friend? e! Flew into my books, acpanied by bright, I walked into the classroom金色的蝴蝶,你愿意和我交朋友吗?来吧!飞进我的课本,伴着我走进明亮的教室 。

Fall to, chrysanthemum opened. There are red, yellow, with purple, and white, very beautiful! 秋天到了,菊花开了。有红的,有黄的,有紫的,还有白的,美丽极了! Do you like autumn? 你喜欢秋天吗? English position英文小作文 My Hobbies I have many hobbies, such as reading, skating, and watching TV. But reading is my favorite hobby. I like reading for three reasons. First of all, books introce me to a new world, which is colorful and with no time and space limit,.Through reading, I can trace back to ancient Egypt, the cradle of human civilization. It can bring myself to the United states, a glamorous land I have been longing to visit. Secondly, reading can improve myself by showing me a new horizon. In the past years, most of my knowledge has been obtained from books. I have learned from many people by reading about their ideas on science, politics, life and society. Thirdly, reading bridges the gap between my dream and my goal. In order to succeed in my career in the future, I must keep reading, thinking and practicing. Reading has bee part of my life. I love reading, 我的爱好

D. Think PHP自带的上传文件类,

上传表单
在ThinkPHP中使用上传功能无需进行特别处理。例如,下面是一个带有附件上传的表单提交:
<form action="__URL__/upload" enctype="multipart/form-data" method="post" >
<input type="text" name="name" />
<input type="file" name="photo" />
<input type="submit" value="提交" >
</form>
注意,要使用上传功能 你的表单需要设置 enctype="multipart/form-data"
多文件上传支持
如果需要使用多个文件上传,只需要修改表单,把
<input type='file' name='photo'>
改为
<input type='file' name='photo1'>
<input type='file' name='photo2'>
<input type='file' name='photo3'>
或者
<input type='file' name='photo[]'>
<input type='file' name='photo[]'>
<input type='file' name='photo[]'>
两种方式的多附件上传系统的文件上传类都可以自动识别。
上传操作
ThinkPHP文件上传操作使用Think\Upload类,假设前面的表单提交到当前控制器的upload方法,我们来看下upload方法的实现代码:
public function upload(){
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = './Uploads/'; // 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
// 上传文件
$info = $upload->upload();
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功
$this->success('上传成功!');
}
}
上传类对图片文件的上传安全做了支持,如果企图上传非法的图像文件,系统会提示 非法图像文件。 为了更好的使用上传功能,建议你的服务器开启finfo模块支持
上传参数
在上传操作之前,我们可以对上传的属性进行一些设置,Upload类支持的属性设置包括:
属性 描述
maxSize 文件上传的最大文件大小(以字节为单位),0为不限大小
rootPath 文件上传保存的根路径
savePath 文件上传的保存路径(相对于根路径)
saveName 上传文件的保存规则,支持数组和字符串方式定义
saveExt 上传文件的保存后缀,不设置的话使用原文件后缀
replace 存在同名文件是否是覆盖,默认为false
exts 允许上传的文件后缀(留空为不限制),使用数组或者逗号分隔的字符串设置,默认为空
mimes 允许上传的文件类型(留空为不限制),使用数组或者逗号分隔的字符串设置,默认为空
autoSub 自动使用子目录保存上传文件 默认为true
subName 子目录创建方式,采用数组或者字符串方式定义
hash 是否生成文件的hash编码 默认为true
callback 检测文件是否存在回调,如果存在返回文件信息数组
上面的属性可以通过两种方式传入:
实例化传入
我们可以在实例化的时候直接传入参数数组,例如:
$config = array(
'maxSize' => 3145728,
'rootPath' => './Uploads/',
'savePath' => '',
'saveName' => array('uniqid',''),
'exts' => array('jpg', 'gif', 'png', 'jpeg'),
'autoSub' => true,
'subName' => array('date','Ymd'),
);
$upload = new \Think\Upload($config);// 实例化上传类
关于saveName和subName的使用后面我们会有详细的描述。
动态赋值
支持在实例化后动态赋值上传参数,例如:
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728;
$upload->rootPath = './Uploads/';
$upload->savePath = '';
$upload->saveName = array('uniqid','');
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');
$upload->autoSub = true;
$upload->subName = array('date','Ymd');
上面的设置和实例化传入的效果是一致的。
上传文件信息
设置好上传的参数后,就可以调用Think\Upload类的upload方法进行附件上传,如果失败,返回false,并且用getError方法获取错误提示信息;如果上传成功,就返回成功上传的文件信息数组。
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = './Uploads/'; // 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
// 上传文件
$info = $upload->upload();
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功 获取上传文件信息
foreach($info as $file){
echo $file['savepath'].$file['savename'];
}
}
每个文件信息又是一个记录了下面信息的数组,包括:
属性 描述
key 附件上传的表单名称
savepath 上传文件的保存路径
name 上传文件的原始名称
savename 上传文件的保存名称
size 上传文件的大小
type 上传文件的MIME类型
ext 上传文件的后缀类型
md5 上传文件的md5哈希验证字符串 仅当hash设置开启后有效
sha1 上传文件的sha1哈希验证字符串 仅当hash设置开启后有效
文件上传成功后,就可以使用这些文件信息来进行其他的数据操作,例如保存到当前数据表或者单独的附件数据表。
例如,下面表示把上传信息保存到数据表的字段:
$model = M('Photo');
// 取得成功上传的文件信息
$info = $upload->upload();
// 保存当前数据对象
$data['photo'] = $info[0]['savename'];
$data['create_time'] = NOW_TIME;
$model->add($data);
单文件上传
upload方法支持多文件上传,有时候,我们只需要上传一个文件,就可以使用Upload类提供的uploadOne方法上传单个文件,例如:
public function upload(){
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = './Uploads/'; // 设置附件上传根目录
// 上传单个文件
$info = $upload->uploadOne($_FILES['photo1']);
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功 获取上传文件信息
echo $info['savepath'].$info['savename'];
}
}
uploadOne方法上传成功后返回的文件信息和upload方法的区别是只有单个文件信息的一维数组。
上传文件的命名规则
上传文件的命名规则(saveName)用于确保文件不会产生冲突或者覆盖的情况。命名规则的定义可以根据你的业务逻辑来调整,不是固定的。例如,如果你采用时间戳的方式来定义命名规范,那么在同时上传多个文件的时候可能产生冲突(因为同一秒内可以上传多个文件),因此你需要根据你的业务需求来设置合适的上传命名规则。这里顺便来说下saveName参数的具体用法。
一、采用函数方式
如果传入的字符串是一个函数名,那么表示采用函数动态生成上传文件名(不包括文件后缀),例如:
// 采用时间戳命名
$upload->saveName = 'time';
// 采用GUID序列命名
$upload->saveName = 'com_create_guid';
也可以采用用户自定义函数
// 采用自定义函数命名
$upload->saveName = 'myfun';
默认的命名规则设置是采用uniqid函数生成一个唯一的字符串序列。
saveName的值支持数组和字符串两种方式,如果是只有一个参数或者没有参数的函数,直接使用字符串设置即可,如果需要传入额外的参数,可以使用数组方式,例如:
// 采用date函数生成命名规则 传入Y-m-d参数
$upload->saveName = array('date','Y-m-d');
// 如果有多个参数需要传入的话 可以使用数组
$upload->saveName = array('myFun',array('__FILE__','val1','val2'));
如果需要使用上传的原始文件名,可以采用__FILE__传入,所以上面的定义规则,最终的结果是 myFun('上传文件名','val1','val2')执行的结果。
二、直接设置上传文件名
如果传入的参数不是一个函数名,那么就会直接当做是上传文件名,例如:
$upload->saveName = time().'_'.mt_rand();
表示上传的文件命名采用时间戳加一个随机数的组合字符串方式。
当然,如果觉得有必要,你还可以固定设置一个上传文件的命名规则,用于固定保存某个上传文件。
$upload->saveName = 'ThinkPHP';
三、保持上传文件名不变
如果你想保持上传的文件名不变,那么只需要设置命名规范为空即可,例如:
$upload->saveName = '';
一般来说不建议保持不变,因为会导致相同的文件名上传后被覆盖的情况。
子目录保存
saveName只是用于设置文件的保存规则,不涉及到目录,如果希望对上传的文件分子目录保存,可以设置autoSub和subName参数来完成,例如:
// 开启子目录保存 并以日期(格式为Ymd)为子目录
$upload->autoSub = true;
$upload->subName = array('date','Ymd');
可以使用自定义函数来保存,例如:
// 开启子目录保存 并调用自定义函数get_user_id生成子目录
$upload->autoSub = true;
$upload->subName = 'get_user_id';
和saveName参数一样,subName的定义可以采用数组和字符串的方式。
注意:如果get_user_id函数未定义的话,会直接以get_user_id字符串作为子目录的名称保存。
子目录保存和文件命名规则可以结合使用。
上传驱动
上传类可以支持不同的环境,通过相应的上传驱动来解决,默认情况下使用本地(Local)上传驱动,当然,你还可以设置当前默认的上传驱动类型,例如:
'FILE_UPLOAD_TYPE' => 'ftp',
'UPLOAD_TYPE_CONFIG' => array(
'host' => '192.168.1.200', //服务器
'port' => 21, //端口
'timeout' => 90, //超时时间
'username' => 'ftp_user', //用户名
'password' => 'ftp_pwd', //密码 ),
表示当前使用Ftp作为上传类的驱动,上传的文件会通过FTP传到指定的远程服务器。
也可以在实例化上传类的时候指定,例如:
$config = array(
'maxSize' = 3145728,
'rootPath' = './Uploads/',
'savePath' = '',
'saveName' = array('uniqid',''),
'exts' = array('jpg', 'gif', 'png', 'jpeg'),
'autoSub' = true,
'subName' = array('date','Ymd'),
);
$ftpConfig = array(
'host' => '192.168.1.200', //服务器
'port' => 21, //端口
'timeout' => 90, //超时时间
'username' => 'ftp_user', //用户名
'password' => 'ftp_pwd', //密码 );
$upload = new \Think\Upload($config,'Ftp',$ftpConfig);// 实例化上传类

E. thinkphp主要有什么用

其实thinkphp是国内自主开发的一款MVC框架,早期是从onethink开始升级而来的。这个框架的话是很符合国人的使用习惯和思维,是作为PHP开发的首要入门级框架,这个框架简单易用,所以很受企业的欢迎。

接下来回答楼主的答案:

  1. thinkphp既然是一个php的MVC框架,那肯定就是用来快速开发用的,可以用来开发任意一款PHP相关的编码系统,无论是商城、管理系统还是搭建博客系统等任意系统。

  2. 其次是主要应用在哪个方面比较好,就我目前在企业开发过程中,其实主要应用在企业类、学校类、新闻类系统的开发比较多。其次是开发商城也比较多。主要是开发方便快捷,懂的人多所被接受。

希望我的回答可以帮到你,有什么不懂可以追问。

F. onethink 安装出错了,请问怎么解决

Errorlaunchinginstaller意思就是安装程序出错这说明你可能已经在某个时候手动地把一些文件直接放入回收站了,而不是一开始就点“添加/卸载程序”,而电脑要卸载程序必须要先访问这些文件后才可以卸载,所以这样会导致系统无法访问这些源文件(也就是找不到源文件),自然就无法删除了。正规操作方式:试试重新下载这个软件进行安装,实在不行,你就先在运行中输入msconfig,选择启动,取消非必要启动项(通常保留杀毒软件和输入法就行,或者全部禁用),然后重新启动,如果还不见效,卸载最近安装的程序后再试试。其他建议:1、干脆就直接干到底,找到文件的路径,然后手动地移到回收站里,也可以达到一样的效果。2、最好是下载一个优化大师,点击智能卸载,也可以的。

热点内容
jffs2解压 发布:2025-02-08 13:55:15 浏览:387
如何向服务器发送大数据包 发布:2025-02-08 13:55:12 浏览:661
服务器pop地址是什么 发布:2025-02-08 13:39:21 浏览:386
网站访问计数器 发布:2025-02-08 13:32:07 浏览:6
钓鱼的腥怎么配置 发布:2025-02-08 13:22:57 浏览:754
php数组的引用 发布:2025-02-08 13:22:54 浏览:94
致远a6服务器地址在哪里看 发布:2025-02-08 13:22:06 浏览:132
bak文件还原数据库 发布:2025-02-08 13:21:34 浏览:103
双向的访问了你的空间 发布:2025-02-08 13:13:20 浏览:701
python元素是否在list 发布:2025-02-08 13:11:38 浏览:695