php代码
<html> <head> <title>图片上传</title> </head> <body> <form enctype="multipart/form-data" method="post" name="upform"> 上传文件:<input type="file" name="upfile" value=""> <input type="submit" value="上传"><br> <?php //能够上传的类型 $uptypes=array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif', 'image/bmp','image/x-png'); ?> 允许上传的文件类型为:<?=implode(',',$uptypes)?> </form> </body> </html> <?php $max_file_szie=2*pow(2,20); //上传的文件小于2MB $destination_folder='uploadimg/'; //上传文件保存路径 if($_SERVER['REQUEST_METHOD']=='POST'){ if(!is_uploaded_file($_FILES['upfile']['tmp_name'])){ echo '图片不存在!'; exit; } if($max_file_szie<$_FILES['upfile']['size']){ echo '文件太大了!'; exit; } if(!in_array($_FILES['upfile']['type'],$uptypes)){ echo '文件类型不符合!'.$_FILES['upfile']['type']; exit; } if(!file_exists($destination_folder)){ mkdir($destination_folder); } $filename=$_FILES['upfile']['tmp_name']; $image_size=getimagesize($filename); $pinfo=pathinfo($_FILES['upfile']['name']); //文件路径信息 $ftype=$pinfo['extension']; //旧文件后缀名 $destination = $destination_folder.time().".".$ftype; //新文件名称 if(file_exists($destination)&&$voerwrie !=true){ echo '同名文件已经存在了!'; exit; } //把上传的文件从临时文件夹移动到指定目录 if(!move_uploaded_file($filename,$destination)){ echo '移动文件出错了!'; exit; } $pinfo=pathinfo($destination); $fname=$pinfo[basename]; echo "<font color='red'>已经成功上传</font><br>文件名: <font color='blue'>".$destination_folder.$fname."</font><br>"; echo '宽度:'.$image_size[0]; echo '高度:'.$image_size[1]; echo '<br>大小:'.$_FILES['upfile']['size']."bytes"; } ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor
