There is a copyright notice in Flash that is not suitable for commercial development. This is the official website address: http://www.hdfu.net/
This document refers to http://blog.csdn.net/yafei450225664/article/details/12855915 and joins its own parsing for subsequent reference.
The demo package provided by the website contains the demo of Php,jsp,asp,aspx.
1, the demo, avatar.swf is to perform the upload of the Flash file, default.jpg is the default display of the picture, Demo.html is the demo, you can directly copy the code inside, Index.html is, the program does not work. Upfile.aspx is to perform the upload of the background files, in fact, we can use the general process to replace, no need to write aspx,xml the actual role of not understanding without modification.
2.demo.html, there are two layers, altcontent store Flash, the contents of the best do not modify, we just need to modify the inside of the path and the default image referenced Flash, Avatar_priview used to display the image after the successful upload can be deleted. JS in uploadevent upload successful execution, status represents the response message value, return 1 indicates success, execution
<script type= "Text/javascript" >functionuploadevent (Status, Picurl, callBackData) {//alert (picurl);//back-end storage picture //alert (callbackdata);Status + = "; Switch(status) { Case' 1 ': varTime =NewDate (). GetTime (); varfilename162 = Picurl + ' _162.jpg '; varfilename48 = Picurl + ' _48.jpg '; varFILENAME20 = Picurl + "_20.jpg"; document.getElementById (' Avatar_priview '). InnerHTML = "Avatar 1: <br/> Avatar 2: <br/> Avatar 3: ; Break; Case'-1 ': Window.location.reload (); Break; default: Window.location.reload (); } } </script>
View Code
This code is only used to display the image after the successful upload, can be modified according to individual needs.
The code in 3.html is as follows
<div id="altcontent"> <ObjectId="Mymoviename"Classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"Height=" the"Width="650"> <param name="movie"Value="avatar.swf"/> <param name="Quality"Value=" High"/> <param name="bgcolor"Value="#FFFFFF"/> <param name="Flashvars"value="Imgurl=./default.jpg&uploadurl=./upfile.aspx&uploadsrc=false"/> <embed align=""allowscriptaccess=" always"Bgcolor="#FFFFFF"Flashvars="Imgurl=./default.jpg&uploadurl=./upfile.aspx&uploadsrc=false"Height=" the"Name="Mymoviename"pluginspage="Http://www.macromedia.com/go/getflashplayer"quality=" High"src="./avatar.swf"Type="Application/x-shockwave-flash"Width="650"Wmode="Transparent"></embed></embed></Object></div><div id="Avatar_priview"></div>
View Code
The code between the <embed></embed> tags is responsible for linking to avatar.swf and upfile.aspx background code and default photos, which can be modified according to individual needs.
4. Background code
<% @Import namespace= "System.IO"%>
<% @Import namespace= "System"%>
<% @ Page language= "C #"%>
<%
DateTime Dtstart = TimeZone.CurrentTimeZone.ToLocalTime (new DateTime (1970,1,1));
DateTime Dtnow = DateTime.Parse (DateTime.Now.ToString ());
TimeSpan Tonow = dtnow.subtract (Dtstart);
String timeStamp = ToNow.Ticks.ToString ();
TimeStamp = timestamp.substring (0,timestamp.length-7);
String Savepath = "./";
String savepicname = TimeStamp;
String file_src = savepath + savepicname + "_src.jpg";
String filename162 = savepath + savepicname + "_162.jpg";
String filename48 = savepath + savepicname + "_48.jpg";
String filename20 = savepath + savepicname + "_20.jpg";
Get three images of the original and modified size:
String pic = request.form["pic"];
String Pic1 = request.form["Pic1"];
String Pic2 = request.form["Pic2"];
String pic3 = request.form["PIC3"];
/* and save with file, of course, if we just need one picture, we can delete the extra code, or we can modify the address of the saved picture. With the address of the picture, we can save the image address to the database directly here.
It is important to note that the return response message
Response.Write ("{\" status\ ": 1}"), can not be modified, if changed to another value, compared to the slice path, then the background to perform the upload is successful, but the foreground cannot respond to upload success, cannot pop up the upload successful box.
If we need to return the post-processing path back to the foreground, you can save the value in the background with a session or a static variable. */
Original
if (pic. Length = = 0) {
}else {
byte[] bytes = convert.frombase64string (pic); Converting a 2-bit encoding into an array of 8-bits unsigned integers
FileStream FS =new FileStream (Server.MapPath (FILE_SRC), System.IO.FileMode.Create);
Fs. Write (bytes, 0, bytes. Length);
Fs. Close ();
}
byte[] bytes1 = convert.frombase64string (PIC1); Converts a 2-encoding into an array of 8-bit unsigned integers.
byte[] Bytes2 = convert.frombase64string (PIC2); Converts a 2-encoding into an array of 8-bit unsigned integers.
byte[] Bytes3 = convert.frombase64string (PIC3); Converts a 2-encoding into an array of 8-bit unsigned integers.
Figure 1
FileStream FS1 =new FileStream (Server.MapPath (filename162), System.IO.FileMode.Create);
FS1. Write (bytes1, 0, Bytes1. Length);
FS1. Close ();
Figure 2
FileStream fs2 =new FileStream (Server.MapPath (filename48), System.IO.FileMode.Create);
FS2. Write (bytes2, 0, Bytes2. Length);
FS2. Close ();
Figure 3
FileStream fs3 =new FileStream (Server.MapPath (FILENAME20), System.IO.FileMode.Create);
Fs3. Write (bytes3, 0, Bytes3. Length);
Fs3. Close ();
String Picurl = Savepath + savepicname;
Response.Write ("{\" status\ ": 1,");
Response.Write ("\" picurl\ ": \" "+picurl+" \ "}");
%>
Next launch Avatar upload three ways of two (swfupload) (ASP) and three (jquery plugin)
The
SWFUpload is a client file Upload tool, originally developed by Vinterwebb.se, which provides Web developers with a rich capability to transcend traditional <input type= "file" by integrating Flash and JavaScript technology. The file upload mode of the/> tag. Another flash plugin used relatively simple, support, local camera upload,
about swfupload Introduction, you can view Baidu Encyclopedia, Blog Park also has SWFUpload2.5 Chinese translation documents.
http://www.cnblogs.com/youring2/archive/2012/07/13/2590010.html
SWFUpload. NET installation package and official demo: ,
http://download.csdn.net/detail/qq14039056961/5246596
The introduction of the two plugins can be learned through the above Web site.