php+js实现图片的上传、裁剪、预览、提交示例_PHP
首先用到的语言是php、插件imgareaselect(下载地址),没有太多花哨的样式,index.php代码如下:
复制代码 代码如下:
//上传图片后,把图片复制到upload文件夹下面
if($_POST){
$photo = $_FILES['img']['name'];
$tmp_addr = $_FILES['img']['tmp_name'];
$path = 'upload/';
$type=array("jpg","gif","jpeg","png");
$tool = substr(strrchr($photo,'.'),1);
if(!in_array(strtolower($tool),$type)){
$text=implode('.',$type);
echo "您只能上传以下类型文件: ",$text,"
";
}else{
$filename = explode(".",$photo); //把上传的文件名以"."好为准做一个数组。
$time = date("m-d-H-i-s"); //取当前上传的时间
$filename[0] = $time; //取文件名
$name = implode(".",$filename); //上传后的文件名
$uploadfile = $path.$name;
$_SESSION['upfile'] = $uploadfile;//上传后的文件名地址
move_uploaded_file($tmp_addr,$uploadfile);
}
// echo $uploadfile;
}
?>
if(isset($_SESSION['upfile'])){?>
}?>

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



How to use Vue and ElementPlus to implement image cropping and rotation functions Introduction: As web applications have higher and higher requirements for user experience, image processing has become a part that cannot be ignored. As a popular JavaScript framework, Vue, combined with ElementPlus, an excellent UI component library, provides us with a wealth of tools and functions to quickly and easily crop and rotate images. This article will be based on Vue and ElementPlus to introduce you to

How to implement image cropping function in JavaScript? With the rapid development of mobile Internet, image cropping functions have become more and more common in many websites and mobile applications. As a front-end development language, JavaScript provides many libraries and technologies to implement image cropping functions. This article will introduce how to use JavaScript to implement the image cropping function and provide specific code examples. 1. HTML structure design First, we need to create a container in the page to display pictures and cropping boxes

WeChat applet implements picture upload function With the development of mobile Internet, WeChat applet has become an indispensable part of people's lives. WeChat mini programs not only provide a wealth of application scenarios, but also support developer-defined functions, including image upload functions. This article will introduce how to implement the image upload function in the WeChat applet and provide specific code examples. 1. Preparatory work Before starting to write code, we need to download and install the WeChat developer tools and register as a WeChat developer. At the same time, you also need to understand WeChat

Steps to implement image upload and display using CakePHP framework Introduction: In modern web applications, image upload and display are common functional requirements. The CakePHP framework provides developers with powerful functions and convenient tools, making it simple and efficient to upload and display images. This article will introduce you to how to use the CakePHP framework to upload and display images. Step 1: Create a file upload form First, we need to create a form in the view file for users to upload images. The following is an example of

Vue.js is a popular JavaScript front-end framework. The latest version - Vue3 has been launched. The new version of Vue has improved performance, size and development experience, and is welcomed by more and more developers. This article will introduce how to use Vue3 to make a simple image cropper. First, we need to create a Vue project and install the required plugins. You can use VueCLI to create a project, or you can build it manually. Here we take the method of using VueCLI as an example: #

How to handle image uploading and compression in Vue technology development In modern web applications, image uploading is a very common requirement. However, due to network transmission and storage reasons, directly uploading original high-resolution images may result in slow upload speeds and a large waste of storage space. Therefore, uploading and compressing images is very important. In Vue technology development, we can use some ready-made solutions to handle image uploading and compression. The following will introduce how to use vue-upload-comone

How to implement image cropping and uploading function in JavaScript? In web development, we often encounter the need for users to upload and crop images, such as avatar uploading, image editing, etc. JavaScript provides a wealth of APIs and functions that can help us implement such functions. This article will introduce how to use JavaScript to implement image cropping and uploading functions, and provide specific code examples. First, we need to add an element for displaying pictures in the HTML file, such as an

Image cropping and scaling through PHP and Imagick Summary: In web development, images often need to be cropped and scaled to suit various needs. This article will introduce how to use PHP and the Imagick library to achieve image cropping and scaling, and provide code examples for readers' reference. Introduction: With the rapid development of the Internet, images play an increasingly important role in web pages. However, since each web page has its own layout and size requirements, images often need to be cropped and scaled to adapt to different scenarios. P
