conn.php:

<?php
$id=mysql_connect('localhost','root','root');
mysql_select_db("db_database12",$id);
mysql_query("set names gb2312");
?>

index.php:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>限制大小的文件上传</title>
<style type="text/css">
<!--
body {
margin-left: 00px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head> <body>
<table width="385" height="185" border="0" cellpadding="0" cellspacing="0" background="image/316.JPG">
<tr>
<td width="130" height="75">&nbsp;</td>
<td width="200">&nbsp;</td>
<td width="55">&nbsp;</td>
</tr>
<form name="form1" method="post" action="index_ok.php" enctype="multipart/form-data">
<tr>
<td height="38">&nbsp;</td>
<td align="center" valign="middle"><input name="file3" type="file" id="file3" size="15" maxlength="150">
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="30" align="right">&nbsp;</td>
<td align="center" valign="top"><input type="submit" name="Submit" value="提交">&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;</td>
</tr>
</form>
<tr>
<td height="42">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

index_ok.php:

<?php
session_start();
include("conn.php");?>
<?php
if($Submit=="提交"){
$data=date("Y-m-d");
$file_name="files";
$filesize=$_FILES['file3']['size'];
if($filesize>2881064151){
echo "对不起,您上传的文件超过了规定的大小!!";
echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上传\">将在3秒钟后返回前页...";
}else{
$path = './upfiles/'. $_FILES['file3']['name'];
if (move_uploaded_file($_FILES['file3']['tmp_name'],$path)) {
$query="insert into tb_file2(file_name,file_text,data)values('$file_name','$path','$data')";
$result=mysql_query($query);
if($result=true){
echo "上传成功!!";
echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上传\">";
}else{echo "文件上传失败!!";
echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上传\">";}
}}}
?>

php如何把文件上传到服务器上的更多相关文章

  1. 基于paramiko将文件上传到服务器上

    通过安装使用paramiko模块,将本地文件上传到服务器上 import paramiko import datetime import os hostname = '服务器ip' username ...

  2. php form 图片上传至服务器上

    本文章也是写给自己看的,因为写的很简洁,连判断都没有,只是直接实现了能上传的功能. 前台: <form action="upload.php" method="PO ...

  3. laravel上传至服务器上出现Whoops, looks like something went wrong.

    1.在本地能够很好运行的laravel,上传至服务器就出现了这个问题“Whoops, looks like something went wrong.”: 2.第一步把config/app.php文件 ...

  4. C# 把本地文件上传到服务器上,和从服务器上下载文件

    方法一.通过Ajax方式上传文件(input file),使用FormData进行Ajax请求 <div  > <input type="file" name=& ...

  5. linux生成公钥私钥并上传到服务器上实现免密登陆

    1. 生成密钥对 # -t 指定加密算法: -b 指定生成的密钥长度: -C 一句话,一般都填邮箱地址. # 更多参数说明可以在终端输入:ssh-keygen --help 查看 ssh-keygen ...

  6. c#将本地文件上传至服务器(内网)

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. 打包vue文件,上传到服务器

    主要步骤: 1. npm run build生成dist文件夹 2. 将dist文件夹上传到服务器上 3. 服务器上配置nginx,访问路径指向dist文件夹下的index.html,这样当访问ngi ...

  8. DedeCMS使用方法----如何将网站上传到服务器

    我们如果在本地已经把网站做好了,上传到服务器上去的正确姿势是什么样的呢?简单的很~跟着我的步调来~ 方法一(推荐此方法): 1.把你本地所有的文件压缩,上传至服务器上的根目录,再解压. 2.把本地的数 ...

  9. jsp项目上传到服务器

    我们通过Myeclipse完成一个Java web项目时只能通过本地访问来查看,但是我们想把它上传到服务器上使用外网访问应该怎么做呢,首先肯定是要有一台服务器 个人调试项目试手的话我建议去买阿里云的云 ...

随机推荐

  1. Java for LeetCode 199 Binary Tree Right Side View

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...

  2. Java for LeetCode 049 Anagrams

    Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...

  3. 5.python(迭代器,装饰器,生成器,基本算法,正则)

    一,迭代器 1.迭代器  (1)迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,知道所有的元素被访问完结束.迭代器只能往前不会后退.  (2)对于原生支持随机访问的数据结构(如t ...

  4. UTF8-GBK WideCharToMultiByte MultiByteToWideChar

    //MFC版本 CString UTF8ToGBK(const CString& strUTF8){ //确定转换为Unicode需要多少缓冲区(返回值也包含了最后一个NULL字符) int ...

  5. [Android Pro] RecyclerView实现瀑布流效果(二)

    referece to : http://blog.csdn.net/u010687392 在上篇中我们知道RecyclerView中默认给我们提供了三种布局管理器,分别是LinearLayoutMa ...

  6. gitlab安装

    [root@localhost ~]# wget https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rp ...

  7. 3.工厂方法模式(Factory Method)

    using System; using System.Reflection; namespace ConsoleApplication1 { class Program { static void M ...

  8. WCF测试客户端的使用

    进入vs安装目录下,C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE,找到WcfTestClient.exe程序,点击文件 ...

  9. [转]Android的Handler总结

    一.Handler的定义:          主要接受子线程发送的数据, 并用此数据配合主线程更新UI.          解释: 当应用程序启动时,Android首先会开启一个主线程 (也就是UI线 ...

  10. JVM的GC理论详解

    GC的概念 GC:Garbage Collection 垃圾收集.这里所谓的垃圾指的是在系统运行过程当中所产生的一些无用的对象,这些对象占据着一定的内存空间,如果长期不被释放,可能导致OOM(堆溢出) ...