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. 使用OkHttp上传图片到服务器

    Okhttp上传图片方法,就像网页那样,使用Form的Post. 首先创建requestBody,然后Builder构建Query:最后Response返回服务器请求,最后把response.body ...

  2. day44-线程

    #1.开启线程: from threading import Thread import os def func(): print('func',os.getpid()) t = Thread(tar ...

  3. ubuntu 14.04 搜狗拼音安装

    打开 Software & Updates,添加软件源: sudo add-apt-repository ppa:fcitx-team/nightly 输入 sudo apt-get inst ...

  4. FastDFS安装部署

    博主本人平和谦逊,热爱学习,读者阅读过程中发现错误的地方,请帮忙指出,感激不尽 服务器信息: Storage:192.168.247.20 Traker:192.168.247.21 一.搭建环境准备 ...

  5. Transformer详解:各个特征维度分析推导

    谷歌在文章<Attention is all you need>中提出的transformer模型.如图主要架构:同样为encoder-decoder模式,左边部分是encoder,右边部 ...

  6. 深入理解 C/C++ 数组和指针

    本文转载自CSDN@WalkingInTheWind,原文链接:https://blog.csdn.net/luckyxiaoqiang/article/details/7044380 C语言中数组和 ...

  7. 吴裕雄--天生自然 人工智能机器学习实战代码:LASSO回归

    import numpy as np import matplotlib.pyplot as plt from sklearn import datasets, linear_model from s ...

  8. <SCOI2009>粉刷匠の思路

    emm.dp真的是写不来啊难过 不边写边注释我就挂了 #include<cstdio> #include<cstring> #include<iostream> # ...

  9. [BZOJ 3144][HNOI 2013] 切糕

    题目大意 切糕是 (p times q times r) 的长方体,每个点有一个违和感 (v_{x, y, z}).先要水平切开切糕(即对于每个纵轴,切面与其有且只有一个交点),要求水平上相邻两点的切 ...

  10. 吴裕雄--天生自然KITTEN编程:拾金币