Here is my problem: I have a website running on IIS 7 + PHP 5.3. There is a virtual directory in the website hierarchy called “vd” which contains flash files.
myApplication
– test.php
– vd
– animation1.swf
– animation2.swf
– …
So, it’s easy to reach the swf files with a browser, you just have to put the directory name in the url: http://www.mySite.com/vd/animation1.swf
However, I would like to use the getimagesize() function on my animations in a PHP script. But in this case, php can’t find the file:
<?php
// test.php
var_dump(getimagesize('vd/animation1.swf')); // false
?>
It seems to make sense because anyway ‘/’ aren’t even the right directory separator for windows. But I just can’t figure out how to make getimagesize works through a virtual directory, I tried a lot of stuff without success (using the DIRECTORY_SEPARATOR constant, using realpath() function …).
Of course, I could use the real path in my script but it would be easier for me to be able to do that throught the virtual path.
Any help would be greaty appreciated,
Thanks!
PHP is not going through the web server but rather the OS to get the file. So, no web server virtual-to-real translations will take place. You will need to use the real path of the file. You could make a web request on the file and deduce the size in that manner but that is very inefficient. It makes much more sense to just do it right through the OS.
Simply create a variable/define/class constant or whatever you prefer to store the real path of the pertinent directory. Then just append
animation1.swfto that in your code.