mjbauer95 Posted June 4, 2008 Share Posted June 4, 2008 Is it possible to read the header of a file with fopen() in php? Link to comment Share on other sites More sharing options...
Lulzim Posted June 4, 2008 Share Posted June 4, 2008 I'm not sure if this is what you're asking for, by file header I think you are looking to get file information such as file size, type, height, width, resolution (for images) etc. There are build-in functions for some of these: image functions, filesystem functionsIf you want to read these informations directly from files, it shouldn't be different from any other language as the file formats are standardized.Here is a table that shows where these informations are saved in some of the file formats.Hope it helped. Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 4, 2008 Share Posted June 4, 2008 On the other hand, if you're asking about HTTP request headers, files don't exactly have those; they're prefixed to files when the files are requested. EDIT: Although that might be the same info that Lulzim mentioned; I don't use those much so I'm not sure. Link to comment Share on other sites More sharing options...
Synook Posted June 4, 2008 Share Posted June 4, 2008 There is the get_headers() function... Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 5, 2008 Share Posted June 5, 2008 Oh, I didn't know about that. But wouldn't it be hard to get that info about a file other than the currently requested one (i.e., the one that called the PHP that needs to know)? Link to comment Share on other sites More sharing options...
Synook Posted June 5, 2008 Share Posted June 5, 2008 You can get_headers() on any file, even a remote one. Though with non-GET requests yes, the headers may be different. $headers = get_headers("http://www.google.com/"); Link to comment Share on other sites More sharing options...
mjbauer95 Posted June 5, 2008 Author Share Posted June 5, 2008 Yah, i think get_headers() will work if it will tell me whether or not the page will be redirected, because i'm having trouble with the php include() function every time i include a page that has a redirect. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.