How to upload LigerUI files in Jquery

Source: Internet
Author: User
Tags bmp image

1. Add in Head

<Script src = "../lib/js/ajaxfileupload. js" type = "text/javascript"> </script>
<Script src = "../lib/js/ligerui. expand. js" type = "text/javascript"> </script>

Ii. Div code in Html

<Div id = "AppendBill_Div" style = "display: none;"> <% -- upload-ticket -- %>
<Table style = "height: 100%; width: 100%">
<Tr style = "height: 40px">
<Td style = "width: 20%">
Icon:
</Td>
<Td> <input type = "file" style = "width: 200px" id = "fileupload" name = "fileupload"/>
</Td>
</Tr>

</Table>

</Div>

3. In Js, what is written is the key part. LigerUI friends will be displayed.-You know

1. Add the item "storage address field" to the grid]
{Display: "scanned copy", name: "AppendBillPath", width: 120, type: "text", align: "left "}
2. You can add a Form item [Save address and pop-up selection box]

{Name: "AppendBillPath1", type: "hidden"}, // -- upload-[5 ]--
{Display: "scanned copy", name: "AppendBillPath", comboboxName: "AppendBillPath2", newline: true, labelWidth: 100, width: 150, space: 30, type: "select", options :{}// -- upload-[6 ]--
$. Ligerui. get ("AppendBillPath2"). set ('onbeforeopen', f_selectAppendBillPath_1) // [scanned copy] // -- upload-[7 ]--
3. Events

// # Region ========================================== === [scan upload window] // -- upload-[8 ]--


Var AppendBillPathDetail = null;
Function f_selectAppendBillPath_1 (){
Var imageurl = $ ("# AppendBill"). val ();
Var AppendBill_Id = $ ("# AppendBill"). val (); // Ticket No.
If (imageurl. length = 0 ){
LG. showError ("You have not entered the order number. Please enter the order number! ");
Return;
}


If (AppendBillPathDetail ){
AppendBillPathDetail. show ();


}
Else {


AppendBillPathDetail = $. ligerDialog. open ({
Target: $ ("# AppendBill_Div"), title: 'add icons ',
Width: 360, height: 170, top: 170, left: 280, // window size displayed
Buttons :[
{Text: 'upload', onclick: function () {AppendBillPath_save ();}},
{Text: 'cancel', onclick: function () {AppendBillPathDetail. hide ();}}
]
});
}
}


Function AppendBillPath_save ()
{


Var imgurl = $ ("# fileupload"). val ();
// Var filehelpcode = $ ("# filehelpcode"). val ();

Var extend = imgurl. substring (imgurl. lastIndexOf ("."), imgurl. length );
Extend = extend. toLowerCase ();
If (extend = ". jpg "| extend = ". jpeg "| extend = ". png "| extend = ". gif "| extend = ". bmp ")
{
}
Else
{


LG. showError ("Upload jpg, jpep, png, gif, and bmp image files ");


Return;
}
Var imageurl = $ ("# AppendBill"). val (); // extend
Alert (imageurl );


$. AjaxFileUpload ({
Url: "../handle/ImageUpload. aspx? Imageurl = "+ imageurl, // -- upload-[9] -- aspx File
Secureuri: false,
FileElementId: "fileupload", // Input file id


DataType: "text ",
Success: function (data, status)
{


// ----------------- // Save path


// $ ("# AppendBillPath2"). val (Data );

LG. tip (data );
F_reload ();
},
Error: function (data, status, e ){
LG. showError (data );


}
});


}


// # Endregion
4. backend cs: Write a key sentence. You can return parameters and the front-end prompts

String url = Server. MapPath ("/Image/" + gfilename + filenameext); // perform the upload operation

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.