Http://www.cnblogs.com/wupeiqi/articles/6307554.htmlSimple to use:class="Comm"> "POST"Enctype="Multipart/form-data"> {% Csrf_token%} "margin:0 Auto;" class="Comment-area"> class="Model {% if Req.session.user_info%} hide {% endif%}">you need to log in before you can reply"/login.html"> Login "/register.html"> Register now "content"Id="content">class="comment-sub"> 255"Button" class="btn btn-primary btn-sm"{%ifNot r
_ size'] = "20000"; // maximum upload size $ this-> load-> library ("upload", $ config ); if ($ this-> upload-> do_upload ('userfile') // name = "userfile" in the form {// After the upload is successful, generate two thumbnails $ data = $ this->
We recommend a good File Upload plug-in bootstrap-fileinput. The C # language is used in the background,
Official tutorial: Http://plugins.krajee.com/file-input#ajax-uploads
Download the official Demo and reference the style and js files. This project stores all the files under one file.
Front-end code
1 /// General Handler-Background code
Supports simultaneous
must remove the upload and delete buttons at the beginning.
After the requirement analysis is completed, Let's explain my Implementation ideas.
2. Implementation ideas
Because this is a form page, if you want to submit the image to the background after uploading, you must definitely need a text field, therefore, when I create a static page, I will take this text
Upload images using AJAX, support image instant browsing, support JS image compression to the serverAjax uploads mainly use var reader = new FileReader () This methodJS image compression is mainly done using canvasSource:/** * js use form to
Objective
The form form contains files, such as image files, normal text files, audio and video files, what to do.There are two total solutions: use Formdata to implement files and text at the same time to submit the first Ajax upload file, return the file URL, and then submit with the text, I called perjury submitted.
Yii2 uses the example code of form Upload File, yii2 form
Yii2 is often used to upload files using forms. How can I upload files?
1. Upload a single file
First, create a model models/UploadForm. php with the following content:
nam
Examples of BootStrap image styles, helper styles, and CSS components are described in detail,
First, add the template code:
Image Style
. Img-responsive: add this style directly to the image to implement a responsive image.
. Center-block: The
Demonstration, relatively humble, not strange, the method is simple!Input is clicked after the default appearance of photos, documents and other options, you can take photos upload, you can also choose the library file upload, you can also record video upload, your own corresponding to modify the file type judgment can beThese features do not need to call the Cor
PHP image upload class; support for watermark-date folder-generating thumbnails; support for multifile Upload
You can use {Y} {m} {n} to change the current date.
Set_dir (dirname (_ FILE __). '/upload/', '{y}/{m}'); // save path. the options {y} {m} {d} are supported.
$ Up-> set_thumb (, 80); //
=%22hello+world%22file=temp.pngsubmit=submitSummarize
(1) We can find that both the POST request and the GET request, their parameters exist in the form of a constant, through the form of key=value exist.
(2) The form item type=filed can only get the name of the obtained file cannot get the contents of the file.
3. Specify what
simple instance:
First, we use Form to create a simple Form:
class UserForm(forms.Form):username = forms.CharField(required=False)headImg = forms.FileField()class UserForm(forms.Form):username = forms.CharField(required=False)headImg = forms.FileField()
This form has two fields, requiring the user to enter the user name and
");//System.out.println (name); //the same Request object gets the true path of the stored pictureString path = Request.getservletcontext (). Getrealpath ("/images"); SYSTEM.OUT.PRINTLN (path);//gets the object that stores the data and sets its corresponding encoding, pathMultipartrequest Mr =NewMultipartrequest (Request, Path, "Utf-8"));//get the original name of the file sent by the foreground.String image = Mr.getoriginalfilename ("
Brief introductionIn the normal front-end development, image upload and avatar upload is Essential. Below I have uploaded the Avatar to do a small example, I hope you can use. The code was written a year ago, for the novice veteran, a look is Understood. If you want to encapsulate the good can add group to find I want to oh!AnalysisUpload images, We need we can c
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.