473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Get a file's version in PHP

Hi there,

I want to get the file version of a file in PHP.

Do somebody have the code for this?

Thanks alot!
Oct 30 '05 #1
7 7638
Marius III wrote:
Hi there,

I want to get the file version of a file in PHP.

Do somebody have the code for this?

Thanks alot!


What do you mean? If you mean the file creation date/last modified date, you
can use the filectime/filemtime functions.
JW

Oct 30 '05 #2
No, I need to get the FileVersion.
For example an EXE files version can be: 2.0.0.260 and a newer version of
this EXE can be 2.0.0.269.
Thanks alot!
Oct 30 '05 #3
Marius III wrote:
Hi there,

I want to get the file version of a file in PHP.

Do somebody have the code for this?

Thanks alot!


which OS are you working on? OpenVMS?
Oct 30 '05 #4
Marius III wrote:
No, I need to get the FileVersion.
For example an EXE files version can be: 2.0.0.260 and a newer
version of this EXE can be 2.0.0.269.


Since you are mentioning EXE files, I assume that you need this for a
Windows environment.

Here, you can use the COM extension (http://www.php.net/com) as follows:

<?php

//create FSO instance
$fso = new COM("Scripting.FileSystemObject")
or die("Could not create Scripting.FileSystemObject");

$version = $fso->GetFileVersion(realpath('some.exe'));
print $version;

?>
JW

Oct 30 '05 #5
Another option, without using COM, would be to open the binary file and
search for the pattern F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0\0\0\0\0
The version is right behind that string:

$strFile = "c:\\my.exe";
$fpFile = fopen($strFile, "rb");
$strFileContent = fread($fpFile, filesize($strFile));
fclose($fpFile);

$strTagBefore = 'F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0\0\0\0\0';
$strTagAfter = '\0\0';
if (preg_match("/$strTagBefore(.*?)$strTagAfter/", $strFileContent,
$arrMatches))
{
print_r($arrMatches);
}

HTH.
Peter.
--
http://www.phpforums.nl
Oct 30 '05 #6
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marius III wrote:
I want to get the file version of a file in PHP.

Do somebody have the code for this?


Yeah, it's called "Use a CVS or SVN repository for version tracking" and
"use external execution commands like shell_exec to query the repository".

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDZK/f3jcQ2mg3Pc8RAmxYAJ4ztjXc/COKd51PaQT5h5SkGPtcSwCeM8rc
7GXQnAGTdtLs9noPiG2R4UU=
=9zCr
-----END PGP SIGNATURE-----
Oct 30 '05 #7
>> I want to get the file version of a file in PHP.

Do somebody have the code for this?

Thanks alot!


What do you mean? If you mean the file creation date/last modified date, you
can use the filectime/filemtime functions.


filectime does not return a "file creation date". Many operating
systems do not even maintain a file creation date. On the UNIX
variants that do keep a file creation date (only on UFS2 filesystems),
that isn't what filectime returns.

Gordon L. Burditt
Oct 30 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Břcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
5
by: Laurence | last post by:
In VS.2005 using VB.NET There are two versions on every project, The Assembly Version and the File Version. Why are there two different versions? As far as I can tell, there is not need for...
1
by: Jerry John | last post by:
I am working in ASP.NET with C#. I have a text file which contains datas with delimiters. For example:- MSH|^~\$|DISCHARGE|CLAY COUNTY MEMORIAL|||200502110939| I also have an XML file created...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
3
by: seb | last post by:
Hi, I am writing to a file some basic information using the logging module. It is working but in the log file some line are printed several time. I had put some print debugging messages in the...
4
by: mcterborg | last post by:
Hello everyone, here is what I want to do. I have a ATI video card and it allows me to setup profiles for monitor configurations and so forth. The shortcut to activate one of these profiles looks...
7
by: dm3281 | last post by:
Hello, I have this non-standard XML file that I have to manually sort thru each day and verify whether various jobs finish successfully or not. This file isn't a real XML file, so I cannot appear...
4
by: Bob Altman | last post by:
Hi all, I have a C++/CLI project (VS 2005) that produces a DLL that exports C bindings. Internally, this DLL contains routines compiled with /clr. I notice that my DLL doesn't have a version...
4
by: nightscorpion | last post by:
Hello Gurus, i implemented the OpenFileDialog in my Windows Form Applications and it worked perfectly fine.However when it was run on a remote desktop i got the below error . ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.