Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    Link information

    I was wondering if I could get information from a link like the file type, file size and if its active or not
    e.g
    http://www.url.com/sub/eek/file.zip
    could i retrive the file size of that zip file, be able to know that its a zip file and if you click on it it will download and not come up with a "The page cannot be displayed" due to the fact the link doesnt exsist.
    I have heard of linkinfo() but no idea how it works
    Help would be great thanks

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    you can simpy use (to see if a file exists) ....with e.g. the url domain.com/download.php?filename=myfile.zip

    PHP Code:
    <?
    //always supply the path here never in the query string
    $filename'/home/user/downloads/'.$_GET['filename'];

    if(
    file_exists($filename)){
     
    //file exists so grab it
     
    header("location:$filename");
    }else{
     
    //bad link
    }
    ?>
    Determining the type other than simply looking at the file extension may require something like mime_content_type()
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    is it possible just to find out what the extention is just by looking at the end of the file after the dot as i get an error when I try mime_content_type() and is it possible to know how big the file is
    and note that the url wont be on my server it will be ok someone elses eg i host the php file that checks to see if this url on this other server works and how big it is and file type
    thanks and sorry if that sounded cofusing but thanks


  •  

    Posting Permissions

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