Uploadify to work with ASP.Net and not MVC
I am trying to work with Uploadify plugin and works fine in uplo开发者_运维问答ading and displaying files.
As a known issue it doesn't supports sessions due to flash and the other fact is that we can work out by using MVC.
But I dosen't know anything about MVC and trying to work with normal Asp.Net application and I have seen many articles regarding Uploadify mentioned below:
http://geekswithblogs.net/apopovsky/archive/2009/05/06/working-around-flash-cookie-bug-in-asp.net-mvc.aspx
http://techblog.edwardting.com/2011/05/20/multiple-file-upload-in-mvc-using-uploadify/
Now I need to get it work with Asp.Net application.
I have created a Global aspx as said in the previous article and now Can anybody explain me in detail so that I need to create a session Id and save all the files in that Session Id and need to retrieve back with the Session Id in the OnComplete event.
So here is my Script code :
<script type="text/javascript">
$(window).load(
function () {
$("#fileInput1").uploadify({
'uploader': 'scripts/uploadify.swf',
'cancelImg': 'images/cancel.png',
'buttonText': 'Browse Files',
'script': 'UploadVB.ashx',
'folder': 'uploads',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'queueSizeLimit': 9999,
'simUploadLimit': 2,
'sizeLimit': 4000000,
'multi': true,
'auto': true,
'onComplete': function (event, queueID, fileObj, response, data) {
$("#thumbnail").append(response)
},
'onError': function (event, ID, fileObj, errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
}
);
</script>
This is my Handler Code:
Dim savepath As String = ""
Dim tempPath As String = ""
tempPath = System.Configuration.ConfigurationManager.AppSettings("FolderPath")
savepath = context.Server.MapPath(tempPath)
Dim filename As String = postedFile.FileName
If Not Directory.Exists(savepath) Then
Directory.CreateDirectory(savepath)
End If
If Not Directory.Exists(savepath + "\thumbs") Then
Directory.CreateDirectory(savepath + "\thumbs")
End If
postedFile.SaveAs((savepath & "\") + filename)
Dim fullImage As System.Drawing.Image = New System.Drawing.Bitmap((savepath & "\") + filename)
Dim newWidth As Integer = 100
Dim newHeight As Integer = 80
Dim temp As New Bitmap(newWidth, newHeight)
Dim newImage As Graphics = Graphics.FromImage(temp)
newImage.DrawImage(fullImage, 0, 0, newWidth, newHeight)
temp.Save((savepath + "\thumbs" & "\") + "t_" + filename)
context.Response.Write("<a href='" + (tempPath & "/") + filename + "'><img src='" + tempPath + "/thumbs" & "/" + "t_" + filename + "'/></a>")
context.Response.StatusCode = 200
精彩评论