Click here to Skip to main content
15,905,508 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: ASP.Net Pin
ZurdoDev25-Feb-16 4:09
professionalZurdoDev25-Feb-16 4:09 
AnswerRe: ASP.Net Pin
F-ES Sitecore25-Feb-16 21:52
professionalF-ES Sitecore25-Feb-16 21:52 
AnswerRe: ASP.Net Pin
Nathan Minier26-Feb-16 1:29
professionalNathan Minier26-Feb-16 1:29 
AnswerRe: ASP.Net Pin
Manas_Kumar26-Feb-16 7:17
professionalManas_Kumar26-Feb-16 7:17 
AnswerRe: ASP.Net Pin
aarif moh shaikh26-Feb-16 21:00
professionalaarif moh shaikh26-Feb-16 21:00 
QuestionPass ViewModel to view twice Pin
Member 1204569224-Feb-16 23:29
Member 1204569224-Feb-16 23:29 
AnswerRe: Pass ViewModel to view twice Pin
Nathan Minier25-Feb-16 1:53
professionalNathan Minier25-Feb-16 1:53 
QuestionGet file size from File Upload from IE and Chrome Pin
indian14324-Feb-16 15:49
indian14324-Feb-16 15:49 
Hi All,

I am using file upload I am trying get the uploaded file size in client script for IE and Chrome browsers I have been trying for it in the below ways. Can any body please help me with that, I have been with no luck so far. One of this approach worked on another application on the same machine and browser and now its not working when I put this on the original larger application.

Any help may be a code snippet, a link or even a suggestion helps.
function CheckImageTypeAndSizeAdd() {<br />
    //var aspFileUpload = document.getElementById("fileUploadCurriculumVitaeAdd");<br />
    //var errorLabel = document.getElementById("lbl_uploadMessageAdd");
    var fileName = $('input[type=file]').val();
    alert(fileName);

    var fileSize; //errorLabel.innerHTML = "";
    alert($('<%= fileUploadCurriculumVitaeAdd.ClientID %>').val);

   <%-- $(function () {
        $('<%= fileUploadCurriculumVitaeAdd.ClientID %>').change(function () {

            //because this is single file upload I use only first index
            var f = this.files[0]
            fileSize = f.size;
            //here I CHECK if the FILE SIZE is bigger than 8 MB (numbers below are in bytes)
            if (f.size > 8388608 || f.fileSize > 8388608) {
                //show an alert to the user
                alert("Allowed file size exceeded. (Max. 8 MB)")

                //reset file upload control
                this.value = null;
            }
        })
    });--%>

    try {
        fileSize = aspFileUpload.files[0].size; // Size returned in bytes.
    } catch (e) {
        var objFSO = new ActiveXObject("Scripting.FileSystemObject");
        var e = objFSO.getFile(fileName);
        fileSize = e.size;
    }
    alert(fileSize);
    var ext = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
    if (!(ext == "docx" || ext == "doc" || ext == "pdf")) {
        errorLabel.innerHTML = "Invalid file type, must select a *.doc, *.docx, or *.pdf file.";
        $('input[type=file]').val() = "No file chosen";
        return false;
    }
    if (fileSize == -1) {
        errorLabel.innerHTML = "Couldn't load doc file size.  Please try to save again.";
        $('input[type=file]').val() = "No file chosen";
        return false;
    }
    else if (fileSize <= 2097152) {
        errorLabel.innerHTML = fileName;
        return true;
    }
    else {
        var fileSize = (fileSize / 1048576);
        errorLabel.innerHTML = "File is too large, must select file under 20 Mb. File  Size: " + fileSize.toFixed(1).toString() + " Mb";
        $('input[type=file]').val() = "No file chosen";
        return false;
    }
}
Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

AnswerRe: Get file size from File Upload from IE and Chrome Pin
F-ES Sitecore25-Feb-16 0:46
professionalF-ES Sitecore25-Feb-16 0:46 
QuestionSet the file upload value Pin
indian14324-Feb-16 11:24
indian14324-Feb-16 11:24 
AnswerRe: Set the file upload value Pin
Richard Deeming25-Feb-16 2:21
mveRichard Deeming25-Feb-16 2:21 
Questionfile upload, restricting size and type of files Pin
indian14324-Feb-16 7:43
indian14324-Feb-16 7:43 
AnswerRe: file upload, restricting size and type of files Pin
Richard Deeming24-Feb-16 7:56
mveRichard Deeming24-Feb-16 7:56 
GeneralRe: file upload, restricting size and type of files Pin
indian14324-Feb-16 12:54
indian14324-Feb-16 12:54 
AnswerRe: file upload, restricting size and type of files Pin
F-ES Sitecore25-Feb-16 0:43
professionalF-ES Sitecore25-Feb-16 0:43 
QuestionHow to filter data in DataTable using like operator ? Pin
Member 1228492023-Feb-16 19:04
Member 1228492023-Feb-16 19:04 
QuestionRe: How to filter data in DataTable using like operator ? Pin
Richard MacCutchan23-Feb-16 21:32
mveRichard MacCutchan23-Feb-16 21:32 
AnswerRe: How to filter data in DataTable using like operator ? Pin
aarif moh shaikh26-Feb-16 21:04
professionalaarif moh shaikh26-Feb-16 21:04 
Questionhow to bind Database field value in textbox based on choosing dropdownlist selected value in asp.net MVC Pin
Nithu Nithiya23-Feb-16 18:06
professionalNithu Nithiya23-Feb-16 18:06 
AnswerRe: how to bind Database field value in textbox based on choosing dropdownlist selected value in asp.net MVC Pin
John C Rayan27-Feb-16 21:39
professionalJohn C Rayan27-Feb-16 21:39 
QuestionDownload file from memorystream by client side click Pin
indian14323-Feb-16 13:33
indian14323-Feb-16 13:33 
AnswerRe: Download file from memorystream by client side click Pin
Richard MacCutchan23-Feb-16 21:29
mveRichard MacCutchan23-Feb-16 21:29 
GeneralRe: Download file from memorystream by client side click Pin
indian14324-Feb-16 7:21
indian14324-Feb-16 7:21 
QuestionDropdownlist with Model (MVC4,C#, ASP.Net2015,Razor) Pin Pin
bl4ckeagle23-Feb-16 8:12
bl4ckeagle23-Feb-16 8:12 
QuestionFeedback form on my website to email feedback Pin
Member 1033668221-Feb-16 11:03
Member 1033668221-Feb-16 11:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.