Giter Site home page Giter Site logo

gerickehoeksema / jquery-file-upload-aspnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from superquinho/jquery-file-upload-aspnet

0.0 2.0 0.0 440 KB

blueimp awesome jQuery File Upload plugin running on VB.net VS2010

ASP 20.98% Visual Basic 15.96% CSS 5.08% JavaScript 57.99%

jquery-file-upload-aspnet's Introduction

jQuery-File-Upload-ASPnet

blueimp awesome jQuery File Upload plugin running on VB.net VS2010

This is an ASP.net project using the awesome jQuery File Upload developed by blueImp (https://github.com/blueimp/jQuery-File-Upload) and adapted to run on server-side with VB.net. To make this run smooth on your machine, all you will need is Visual Studio 2010 installed. Some of important changes made for this project to run are:

- on FileUpload\js\jquery.fileupload-ui.js it maximum size allowed for a single file is set to 100kb.
// The maximum allowed file size:
maxFileSize: 100000,

- also on the same .js file, the maximum number of files allowed for this project is set to 5 total files per upload.
This will reset once the user reload the page. (on Page_Load, Not IsPostBack)
// The following option limits the number of files that are
// allowed to be uploaded using this widget:
maxNumberOfFiles: 5,

- for the previous to run smooth, a changed was necessary in 2 places, that was resetting as soon as the files were uploaded, allowing the user to upload another set of 5 files.

on application.js the following were commented off:
// Don't allow to add another file for each successfull File uploaded
//fu._adjustMaxNumberOfFiles(JSONjQueryObject.List.length);

on jquery.fileupload-ui.js the following were commented off:
// Don't allow to add another file for each successfull File uploaded
//that._adjustMaxNumberOfFiles(1);

- the property filePath was added to the file variable on jquery.fileupload.js in case the internet browser is IE and the security setting enables
"Initialize and Script ActiveX controls not marked as safe for scripting"
so the file size of each uploading file is retrieved correctly, otherwise, "N/A kb" and the Handler.ashx will do another check on the server-side.

- on appSettings in web.config file has some very important information regarding the Handler.ashx process.
add key="UploadFilesTempBasePath" value="C:\"
add key="UploadFilesTempPath" value="docs\jQueryFileUpload\"
add key="UploadFilesMaximumFileSize" value="100" -- value in KB --
if you planning on adding more server-side check (i.e. acceptFileTypes , maxNumberOfFiles, etc) it should be added in here and implement the code on Handler.ashx.

- since IE might won't return the file size, a check is made on Handler.ashx if the browser is IE, and then using the setting on web.config, it will verify if the file size is within the limit.
Dim maximumFileSize As Integer = ConfigurationManager.AppSettings("UploadFilesMaximumFileSize")
If hpf.ContentLength >= 0 And (hpf.ContentLength <= maximumFileSize * 1000 Or maximumFileSize = 0) Then

- on file jquery.fileupload-ui.js the following code was added to retrieve any erros message from Handler.ashx:
var files = data.result;
if (files.Value._errorMSG != null) {
file.error = files.Value._errorMSG;
}

- on file jquery.fileupload-ui.js the following code was added to control which files has been uploaded using the jQuery plugin:
// Adding the files to a TextBox
AddTxtFileName(data.files[index].name);

Everything else is pretty much the same.

So, feel free to make any changes to run according to your requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.