1、前端代码

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>销售数据修改</title>
</head>
<body>
<div>
<form enctype='multipart/form-data' id='aa' name='aaa' method='post' action='Platform.php?c=ClarksDataKids&m=uploadFile'>
<!-- <input type='hidden' name='MAX_FILE_SIZE' value='2621114' /> -->
<input name='file' style="cursor:pointer;" type='file' />
<input type="submit" style="cursor:pointer;" value="上传修改数据"/>
</form> </div>
</body>
</html>

2、后端PHP代码

function uploadFile() {
if (!$_FILES['file']['tmp_name']||!$_FILES['file']['name']){
echo "<script>alert('请选择要上传的文件!');history.go(-1);location.reload();</script>";
exit();
}
$fileName = basename($_FILES['file']['name']);
$tempName = $_FILES['file']['tmp_name']; $date = date("Ymd",time());
$dir = "/home/wwwroot/erp/FTP/Women/".$date;
chmod($dir, 0777); //修改文件权限
if (!is_dir($dir)){
mkdir($dir,0777,true);//创建多级目录
//echo "<script type='text/javascript'>alert('请在有效的时间内执行修改操作!');history.go(-1);location.reload();</script>";
//exit();
}
$newFile = $dir."/".$fileName; if (is_uploaded_file($_FILES['file']['tmp_name'])){
$res = move_uploaded_file($_FILES['file']['tmp_name'], iconv("gb2312", "UTF-8", $newFile)); if (!$res){
echo "<script>alert('上传失败');history.go(-1);location.reload();</script>";
}else {
echo "<script>alert('上传成功');history.go(-1);location.reload();</script>";
}
} }

PHP文件上传 (以上传txt文件为例)的更多相关文章

  1. WPF: 读取XPS文件或将word、txt文件转化为XPS文件

    读取XPS格式文件或将doc,txt文件转化为XPS文件,效果图如下: 1.XAML页面代码: <Window x:Class="WpfWord.MainWindow" xm ...

  2. WFP: 读取XPS文件或将word、txt文件转化为XPS文件

    读取XPS格式文件或将doc,txt文件转化为XPS文件,效果图如下: 1.XAML页面代码: <Window x:Class="WpfWord.MainWindow"    ...

  3. 读取同一文件夹下多个txt文件中的特定内容并做统计

    读取同一文件夹下多个txt文件中的特定内容并做统计 有网友在问,C#读取同一文件夹下多个txt文件中的特定内容,并把各个文本的数据做统计. 昨晚Insus.NET抽上些少时间,来实现此问题,加强自身的 ...

  4. C++实现从一个文件夹中读出所有txt文件

    前段时间做项目需要读取一个文件夹里面所有的txt文件,查询资料后得到以下实现方法:首先了解一下这个结构体struct _finddata_t {    unsigned    attrib;    t ...

  5. MATLAB实例:新建文件夹,保存.mat文件并保存数据到.txt文件中

    MATLAB实例:新建文件夹,保存.mat文件并保存数据到.txt文件中 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 用MATLAB实现:指定路径下 ...

  6. c# txt 文件上传、写入TXT文件、创建图形验证码

    asp.net mvc 图片上传 html 在使用包含文件上传控件的表单时,必须使用 enctype="multipart/form-data" 属性 <form encty ...

  7. matlab如何读取未知行数,带头文件和字段名的txt文件

    文件格式是这样的 20120108 50024 X235RZB30801 01 15 2361 2362 2363 2364 2365 2366 2367 2368 2369 236A 236B 23 ...

  8. VBA读取可选择文件夹下可选择txt文件内容

    Sub OneTxt() '打开一个txt文件 Dim Filename As Variant, extLine&, mArr() As String Dim i%, j% ChDir Thi ...

  9. C# 读取网络txt文件 并写在本地txt文件中

    public void WriteStream() { try { stirng ImagesPath = ImagesPath + "\\2013-09-27.txt"; Htt ...

  10. c++--------获取某个路径下所有文件的文件名,读写TXT文件到新的文件

    好久没写io操作了,手生了好多,为了防止自己老年痴呆,最简单实用的c++代码也push上来吧, 环境:mac,xcode(注意mac环境下Windows的函数不能用) 功能:打开一个文件目录,把所有文 ...

随机推荐

  1. Trying to find the anti-derivative of $\tan x$ unsuccessfully by using Euler's formula

    We know that$$\tan t=\frac{e^{it}-e^{-it}}{i(e^{it}+e^{-it})}=\frac{e^{2i    t}+1-2}{i(e^{2it}+1)}=- ...

  2. JSP详细解析

    原文地址: http://www.cnblogs.com/rollenholt/archive/2011/07/04/2097376.html http://www.cnblogs.com/jy024 ...

  3. 56)PHP,模型类的设计思想

    一张表对应一个模型类-----Mode

  4. Image.FromStream(ms) 提示参数无效

    说明ms有问题,首先确保有读到数据,这种情况是保存到库的时候出错的. 原来你可能是这样写的: MemoryStream stream = new MemoryStream();PictureBox1. ...

  5. java replaceall 用法:处理特殊字符

    public class TryDotRegEx { public static void main(String[] args) { // TODO Auto-generated method st ...

  6. log4j2.xml 配置

    动态生成日志, 日志路径: log4j2.xml 配置如下: <?xml version="1.0" encoding="UTF-8"?> < ...

  7. jsp读取后台数据乱码

    jsp读取后台数据乱码,如图所示: tomcat编码格式与项目不一致,找到config/server.xml修改为UTF-8 <Connector URIEncoding="UTF-8 ...

  8. matplotlib.pyplot.contour 简单等高线绘制

    contour(X, Y, Z) X,Y是与Z形状相同的二维数组,可以通过 numpy.meshgrid()创建. numpy.meshgrid()----从坐标向量返回坐标矩阵 生成的x,y坐标矩阵 ...

  9. asp.net 获取日期

    //获取日期+时间 DateTime.Now.ToString(); // 2008-9-4 20:02:10 DateTime.Now.ToLocalTime().ToString(); // 20 ...

  10. 作业:for循环,迭代法和穷举法

                                                    for()循环 四要素:初始条件,循环条件,状态改变,循环体. 执行过程:初始条件--循环条件--循环体 ...