Results 1 to 5 of 5

Thread: how to check file type in a file path

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Question how to check file type in a file path

    i have create one file input type for upload file......how to check the path in the text field is what i want? i mean like only able to upload jpg file, gif file and so on.....is it need java script?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how to check file type in a file path

    You would need to do a server-side validation (such as PHP, ASP, CGI, etc) for that. Even then, it is not straightforward to check the type, although you could just assume the file extension is correct.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: how to check file type in a file path

    how about this lines code, is it about validate the file type??

    Code:
    if((document.form1.upload.value.lastIndexOf(\”.jpg\”)==-1) {
       alert(\”Please upload only .jpg extention file\”);
       return false;
    }

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how to check file type in a file path

    And if I have Javascript disabled? (Which, BTW, I do for most sites).

    That's why you need a server-side check. Maybe a JS one too but always a server-side to fall back on.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: how to check file type in a file path

    ok........i will do server-side validation.!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width