SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Leting upload only .php/.html/.htm

    I'm trying to make script which lets upload file containing html. But uploadnig those files, it says those type is "application/octet-stream".
    So how do I determin that uploaded file is correct allowed type.

    Thanks,
    Sander

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:

    PHP Code:
    if (preg_match('#\.(php|html?)$#'$file))
    {
       
    // extension is either .php, .html or .htm

    This checks if the files end with the proper extension.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course regular expression is another solution

    Thanks,
    Sander


Bookmarks

Posting Permissions

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