html前台文件,上传到控制器,thinkphp处理它

前台

    <form action="{:url('product/brand_addcl')}" enctype="multipart/form-data" method="post" class="form form-horizontal" id="form-article-add">

        <div class="row cl">
<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>缩略图:</label>
<div class="formControls col-xs-8 col-sm-9">
<input accept="image/*" type="file" name="image" />
</div>
</div> <div class="row cl">
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
<button type="submit" onClick="article_save_submit();" class="btn btn-primary radius" type="submit"> 添加</button>
</div>
</div>
</form>

后台

    //品牌添加处理
public function brand_addcl(){ $file = request()->file('image');
if(!$file){
$this->error('图片文件接收报错!');
} //存储到本地,路径从public开始
$info = $file->move("static/uploads/");
if(!$info){
$this->error('图片文件存储报错!');
}
$data['logo_img'] = $info->getSaveName(); $res = Brand::create($data);
if(!$res){
$this->error('添加品牌失败!');
}
echo "<script language=JavaScript> alert('操作成功!');
parent.location.reload();
</script>";
}

thinkphp 接收文件并处理的更多相关文章

  1. 第一个thinkphp入口文件

    ThinkPHP3.1.3_full已下载 网站根目录下编辑一个入口文件index.php <?php define('APP_NAME','Index'); //项目名称 define('AP ...

  2. 应用SecureCRT(发送接收文件)

    使用 SecureCRT 和 cz. sz,可以从 Linux 服务器上下载/上传文件. Linux 上要安装 lszrz 包 (1)编译安装root 账号登陆后,依次执行以下命令 cd /tmp w ...

  3. thinkphp对文件的上传,删除,下载操作

    工作需要,整理一下最近对php的学习经验,希望能对自己有帮助或者能帮助那些需要帮助的人. thinkphp对文件的操作,相对来说比较简单,因为tp封装好了一个上传类Upload.class.php 废 ...

  4. ubuntu-apache下隐藏thinkphp入口文件index.php

    按照thinkphp手册中来讲,apache服务器下,隐藏thinkphp入口文件有3步: httpd.conf配置文件中加载了mod_rewrite.so模块 AllowOverride None ...

  5. 在Django中接收文件并存储

    首先是一个views函数的例子 def get_user_profiles(request): if request.method == 'POST': myFile = request.FILES. ...

  6. python requests上传文件 tornado 接收文件

    requests 上传文件 import requests def images(): url = 'http://127.0.0.1:8889/upload/image' files = {'fil ...

  7. django设置并获取cookie/session,文件上传,ajax接收文件,post/get请求及跨域请求等的方法

    django设置并获取cookie/session,文件上传,ajax接收文件等的方法: views.py文件: from django.shortcuts import render,HttpRes ...

  8. 需求:过滤下面这个网页里共723行 校对中里 行数为两位数的 行 并设置sz和rz在Windows和Linux之间发送和接收文件不用搭FTP

    需求:过滤下面这个网页里共723行 校对中里 行数为两位数的 行 并设置sz和rz在Windows和Linux之间发送和接收文件不用搭FTP 需求:过滤下面这个网页里共723行 校对中里 行数为两位数 ...

  9. C#网络编程(接收文件) - Part.5

    这篇文章将完成 Part.4 中剩余的部分,它们本来是一篇完整的文章,但是因为上一篇比较长,合并起来页数太多,浏览起来可能会比较不方便,我就将它拆为两篇了,本文便是它的后半部分.我们继续进行上一篇没有 ...

随机推荐

  1. c++ md5算法实现(转)

    原文链接:C++计算文件的MD5值 其他:c++输入文件流ifstream用法详解

  2. 在Visual Studio中将dll以资源的形式嵌入exe中

    一.Dll的优点: 1.扩展应用程序的特性 2.简化项目管理 3.有助于节省内存 4.促进资源的共享 5.促进本地化 6.有助于解决平台间的差异 7.可用于特殊目的 有关于dll及注入相关理论资料,可 ...

  3. mac /windows

    1.mac 和 windows 同样的浏览器展示的样式有偏差 考虑:字体的问题,mac/windows 的字体不一样 font-family 用法

  4. ubuntu中的Linux安装程序的方法

    Ubuntu: 1.下载.deb文件,下载后,cd到.deb文件目录,然后使用sudo dpkg -i xxx.deb      dpkg=debian packager的缩写  -i=install ...

  5. 关于springboot连接数据库失败时,系统报错 MySQL:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents .....

    起初在遇到这个问题时,当然知道是怎么回事,但因为是新手,也不知道怎么处理... 百度了下,发现网上很多攻城狮们都是在mysql的命令行界面处理. 先输入命令:show variables like ' ...

  6. 栈和队列----设计一个有getMin功能的栈

    设计一个有getMin功能的栈 设计一个具有getMin功能的栈,可以返回栈中的最小的元素,可以使用现有的栈的数据结构,要求pop/push/getMin操作的时间复杂度是O(1). package ...

  7. 【kuangbin带你飞】 MST专题

    唉,被班级合唱和复变考试搞得心力交瘁.新算法学不进去,更新下吧 A - Til the Cows Come Home The Head Elder of the tropical island of ...

  8. 《深入理解java虚拟机》读书笔记四——第五章

    第五章 调优案例分析与实战

  9. Codeforces 577A - Multiplication Table

    Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i ...

  10. 展开折叠效果 height未知 transition无效

    展开折叠效果,没有设置height时 transition 不起作用 可以设置max-height .default { max-height: 500px; transition: all 1000 ...