...

View Full Version : Link information



tsclan
05-24-2004, 02:29 AM
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

firepages
05-24-2004, 10:27 AM
you can simpy use (to see if a file exists) ....with e.g. the url domain.com/download.php?filename=myfile.zip



<?
//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() (http://php.net/mime_content_type)

tsclan
05-24-2004, 04:08 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum