上传文件代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上传文件</title>
<style type="text/css">
<!--
.STYLE1 {
	font-size: 36px;
	color: #990000;
	font-weight: bold;
}
body,td,th {
	font-size: 12px;
}
-->
</style>
</head>

<body>
<div align="center">
  <form action="uploading_ok.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <table id="__01" width="800" height="600" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="523" height="251" align="center" valign="top"><table width="460" height="232" border="1" align="center">
          <tr>
            <td width="150" height="30">文件名称:</td>
            <td width="310" align="left"><input name="fileName" type="text" size="40" /></td>
          </tr>
          <tr>
            <td  width="150" height="30">文件上传:(<font color="#FF0000">.xls文件</font>)</td>
            <td align="left"><input name="files" type="file" size="31" /></td>
          </tr>
          <tr>
            <td height="30" colspan="2"><div align="center">
                <input type="submit" name="Submit" value="上传" />
                    
                <input type="reset" name="Reset" value="取消" />
            </div></td>
          </tr>
        </table></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html><pre name="code" class="php"><?php
header("content-type:text/html;charset=utf-8");

if(isset($_POST['fileName']) and $_POST['Submit']=="上传")
{
	if(isset($_FILES['files']['name'])) //判断文件是否存在
	{
		$fileName = 'dir\\' . 'myfile'. ".xls"; //文件的存储路径和名称
		$fileName = iconv("utf-8","gb2312//IGNORE",$fileName);

		if(move_uploaded_file($_FILES['files']['tmp_name'], $fileName))
		{	//执行上传
			echo "<script>alert('上传成功!');</script>";
			include("buildFile.php");
		}
		else
		{
			echo "<script>alert('复制文件失败!');</script>";
		}
	}
	else
	{
		echo "<script>alert('文件不存在!');</script>";
	}
}
else
{
	echo "<script>alert('请选择上传文件!');</script>";
}
echo "<script>window.location.href='display_updata.php';</script>";
?>
				
时间: 2024-08-03 11:28:22

上传文件代码的相关文章

jquery ajax实现上传文件代码,带进度条

原文:jquery ajax实现上传文件代码,带进度条 源代码下载地址:http://www.zuidaima.com/share/1550463291116544.htm ajax上传文件代码,带进度条的. 首页 http://localhost:端口/项目名/common/test.htm 上传中 标签: jquery ajax 上传 进度条话题: Web开发 前端技术 jquery ajax实现上传文件代码,带进度条

Drupal创建自定义表单,上传文件代码

Drupal中创建自定义表单,用来上传文件,对上传文件做一些操作.以下是放在Module中的代码: 一.菜单建立表单路径 /** Implementation of hook_menu(). */ function moduleName_menu () { $items = array(); $items['admin/import'] = array( 'title' => 'title', 'page callback' => 'drupal_get_form', 'page argume

ExtJS + fileuploadfield上传文件代码

后台服务端接收文件的代码: /** * 后台上传文件处理Action */ @RequestMapping(value = "/uploadFile", method=RequestMethod.POST) public void uploadFile(@RequestParam(value="file",required=true) MultipartFile file ,HttpServletResponse response) { ModelMap model

PHP上传文件代码练习2 (重复文章)

表单: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题</title> </head> <body> <form action="upload.php" method="post" enctype=

javaWeb上传文件代码

javaweb两种方式的上传,1普通上传,2:jquery ajax后台上传,部分截图如下: 完成包下载,下载后倒入myeclipse工程即可,下载地址:http://files.cnblogs.com/files/haha12/uploadDemo.rar

easyui 上传文件代码

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.IO;using BLL;using m = Model;using System.Data;using System.Data.SqlClient;using System.Text;namespace Web.Handler{ /// <summary> /// AddOppportunityHandle

socket 上传文件代码

server.py #!/usr/bin/env python# -*- coding:utf-8 -*- import socketimport os,hashlib ip_port = ('127.0.0.1',6969)sk = socket.socket()sk.bind(ip_port)sk.listen(5) while True: conn,address = sk.accept() while True: print('等待新指令') #获取客户端发来的操作指令 data = c

jsp 上传文件代码

curl的http上传文件代码

int http_post_file(const char *url, const char *user, const char *pwd, const char *filename){    assert(url != NULL);    assert(user != NULL);    assert(pwd != NULL);    assert(filename != NULL); int ret = -1;    CURL *curl = NULL;    CURLcode code;