I'm using the current version of XAMPP (5.6.12) with PHP version 5.6.12 and Apache 2.4.16 (Win32) on Windows 8.1.
The two sites (both found off of the \xampp\htdocs directory) are MAIN and STATIC, and are configured appropriately in the httpd-vhosts.conf file as well in the Windows hosts file. So, they each work, and each can retrieve content from the other (with the important exception explained below).
In STATIC there is a subdirectory named IMAGES containing MY.JPG; its local URL is therefore STATIC/IMAGES/MY.JPG when XAMPP is running, and it does display.
Within the files of my MAIN local domain, I can reference content on the STATIC local domain by prefixing the domain name with two forward-slashes, e.g., //STATIC/IMAGES/MY.JPG. And in fact, this code in my STATIC domain's INDEX.PHP will in fact retrieve and display the JPG:
- Code: Select all
<img style="display: inline;" src="//STATIC/IMAGES/MY.JPG" />
No problem there. But when I pass that path to getimagesize() or other PHP operators, like this:
- Code: Select all
$resource = "//STATIC/IMAGES/MY.JPG";
$getimagesize = getimagesize($resource);
...I get a message like this:
Warning: getimagesize(//tmb-static/images/my.jpg): failed to open stream: Permission denied in C:\xampp\htdocs\MAIN\INDEX.PHP on line 11
After reading about similar problems encountered by others, I checked to ensure that correct permissions are set for the folder I'm trying to open. To determine who the current user is when I execute this code locally, I ran:
- Code: Select all
$current_user = get_current_user();
print_r("current_user = " . $current_user . "\n");
...and it showed that the current user is SYSTEM.
I then did what has been suggested elsewhere, which is to give complete read, write, and all other accesses to SYSTEM for the STATIC folder and its subfolders, by following the appropriate steps for sharing folders and setting permission. I did this not only for SYSTEM but also for Everyone, just in case.
Sadly, getimagesize() and similar operators throw the same "failed to open stream: Permission denied" message when I then ran the code, even though the image itself can be retrieved and displayed using simple HTML:
- Code: Select all
// This works and displays the retrieved image:
echo '<img style="display: inline;" src="//STATIC/IMAGES/MY.JPG" />';
// This immediately fails with message: "failed to open stream: Permission denied..."
$getimagesize = getimagesize('//STATIC/IMAGES/MY.JPG');
Provided that I've given full control to the STATIC folder and subfolders, as well as to the parent HTDOCS folder as well, what could be the cause and solution to this vexing problem?
UPDATE: By prefixing the STATIC URL with http:, like this:
- Code: Select all
http://STATIC/IMAGES/MY.JPG
...the error changes to
failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
But is this a red herring? Or is this just another layer of the problem, with the prefixing of HTTP: being the first step?