Use of Webuploader

Source: Internet
Author: User

This article mainly introduces the use of Webuploader, has a certain reference value, and now share to everyone, the need for friends can refer to the

var uploader = Webuploader.uploader ({//several common parameters: Swf,pick,formdata,runtimeorder//All parameter list swf: ' PATH_OF_SW      F/uploader.swf ', DND: ' #dndArea ',//[default: undefined] Specifies drag and drop dragged container, if not specified, does not start. Disableglobaldnd:true,,//[default: false] To disable the drag-and-drop function of the entire page, if not disabled, the picture will be dragged in by default when the browser opens paste: ' #uploader ',//[default: Undefined] Specifies the container that listens for paste events, and if not specified, does not enable this feature. This feature is a picture that adds a screenshot by pasting. The recommended setting is document.body. Pick: ' #filePicker ',//can also be configured in detail in the following way//{Selector, Object} [default: Undefined] Specifies the button container for selecting a file, without specifying the      Build button. Pick: {ID: ' #filePicker ',//seletor|dom specifies the button container for the selected file, and no button is created without specifying it.          Note that although the ID is written here, it does not only support ID, but also class, or DOM nodes. Label: ' Click to select Image ',//please use InnerHTML instead of InnerHTML: "Click to select Picture"//Specify button text.          When not specified, takes precedence from the specified container to see if the text is self-containing.      Multiple:true//whether to open the simultaneous selection of multiple file capabilities. },//Limit uploaded file type accept: {title: ' Images ',//{String} literal description extensions: ' Gif,jpg,jpeg,bmp,png,ra          R ',//{String} allowed file suffix, without dot, multiple separated by commas. Mimetypes: ' Image/gif,image/jpg,image/jpeg,imAge/bmp,image/png,.rar '//multiple separated by commas.      },//set the thumbnail image.          Thumb: {width:110, height:110,//Picture quality, only valid when type is ' image/jpeg '.          QUALITY:70,//whether to allow amplification, if you want to generate a small image without distortion, this option should be set to false. Allowmagnify:true,//whether clipping is allowed. Whether to use cropping mode.          If you use this, you can avoid whitespace content.          Crop:true,//empty if the original image format is preserved.          Otherwise, cast to the specified type. Type: ' Image/jpeg '},//option to configure compressed pictures.      If this option is false, the picture is not compressed until it is uploaded.          Compress: {width:1600, height:1600,//Picture quality, only valid when type is ' image/jpeg '.          QUALITY:90,//whether to allow amplification, if you want to generate a small image without distortion, this option should be set to false.          Allowmagnify:false,//whether clipping is allowed.          Crop:false,//whether to retain header meta information. Preserveheaders:true,//If the compressed file size is larger than the original, then using the original image//This property may affect the image Auto-correction function nocompressiflarger:fals          E,//unit byte, if the picture size is less than this value, compression is not used. compresssize:0}, Auto:true,//[default: false] set to true, do not need to manually invoke the upload, there is a file selection that starts onMass transfer Runtimeorder: ' Flash ',//[default: Html5,flash] Specifies the run-time boot order.      The default is to try HTML5 support, and if supported, use HTML5, otherwise flash is used. This value can be set to flash to force the use of the Flash runtime. Preparenextfile:false,//[default: false] allows the next file to be ready in advance when the file is transferred. Preparation for a file is time consuming, compared to slice compression, MD5 serialization.      If you can process the current file transfer period in advance, you can save overall time.      Chunked:false,//[default: false] whether to shard large file uploads. chunksize:512 * 1024,//[default: 5242880] If you want to Shard, how big a piece?      The default size is 5M.      Chunkretry:2,//[default: 2] If a shard is faulty due to a network problem, how many times does it allow automatic retransmission? Threads:3,//[default: 3] upload concurrency number.      The maximum number of simultaneous upload processes allowed.      FormData: {"test": "123123", "Shui": "Ping"},//[default: {}] File upload request parameter table, each send will send parameters in this object.      Fileval: "Pictures",//[Default: ' File '] sets the name of the file upload domain.      Method: "POST",//[Default: ' Post '] File upload method, post or get.      Sendasbinary:false,//[default: false] Whether the file is sent as a binary stream, so that the entire upload content Php://input is the contents of the file, and the other parameters are in the $_get array.      Filenumlimit:10,//[default: undefined] Verifies the total number of files, exceeding the queue is not allowed.      filesizelimit:200 * 1024x768 *,//////////[Default: undefined] Verify that the total file size exceeds the limit and the queue is not allowed. FILESINGLESIZELIMIT:50 * 1024x768 * 1024x768,///[Default value: UndefinEd] verifies that a single file size exceeds the limit and is not allowed to join the queue.      Duplicate:true,//[default: undefined], to generate hash Key based on file name, file size, and last modified time.  Disablewidgets: {String, Array},//[default: undefined] All widgets that are uploader.register by default will be loaded, and if a part is disabled, specify the blacklist by this option. });

Back-end PHP, with the Laravel framework, very convenient:

Public Function UploadFile (Request $request) {set_time_limit (100);    DD (Request ()->all ());        $type = Request (' type ', 0); if ($type = = 1) {$rules = [' Document ' = ' SOMETIMES|REQUIRED|FILE|MIMES:WORD,PPT,PDF,JPG,PNG,JP    Eg|max:10240 ',];    } else {$rules = [' File ' = ' required|image|max:2048 ',];        } $validator = Validator::make ($request->all (), $rules);              if ($validator->fails ()) {$error _message = $validator->errors ()->all (); return $type = = 1?    False: $this->outputjson ("', 501, $error _message); } $file = $type = = 1?            $request->file (' document '): $request->file (' file ');            $save _path = ' courseware ';    $mime _type = $file->getclientoriginalextension (); Save the file $save _name = date (' Ymd_h_i_s_ '). Uniqid (). '.' .        $mime _type;        $path = $file->storeas ($save _path, $save _name, ' ftp '); Return $type = = 1? $path: $this->outputjson ($path);}

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.