By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

[function.getimagesize]: failed to open stream & unable to display XML content

P: 6
Hi,

My application is working fine on server A, which is using PHP 4.4.1. However, after it is copied over to server B, which is using PHP 4.4.6, I got several problems related to pdf and xml.

1) I got this message when i tried to generate a pdf, with image:

getimagesize(http://www.myweb.com/image/photo_2.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/vhosts/myweb.com/httpdocs/folder/myphoto.php on line 103

FPDF error: Missing or incorrect image file: http://www.myweb.com/image/photo_2.jpg

The image is actually there (tested with the direct URL) with all the folder and file permission set to 777. Wonder why it can't read the image?


2) I got this message when i tried to display the contents from a xml file:

Not Found
The requested URL /document/xml/profile.xml was not found on this server.

The xml file is actually exists (tested with the direct URL) with all the folder and file permission set to 777. Any idea about what is missing?
Thanks in advance!
May 18 '07 #1
Share this Question
Share on Google+
7 Replies


Motoma
Expert 2.5K+
P: 3,235
I would suggest using relative URLs to start with, and if those work, begin working your way up to full pathnames for these files.

Hi,

My application is working fine on server A, which is using PHP 4.4.1. However, after it is copied over to server B, which is using PHP 4.4.6, I got several problems related to pdf and xml.

1) I got this message when i tried to generate a pdf, with image:

getimagesize(http://www.myweb.com/image/photo_2.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/vhosts/myweb.com/httpdocs/folder/myphoto.php on line 103

FPDF error: Missing or incorrect image file: http://www.myweb.com/image/photo_2.jpg

The image is actually there (tested with the direct URL) with all the folder and file permission set to 777. Wonder why it can't read the image?


2) I got this message when i tried to display the contents from a xml file:

Not Found
The requested URL /document/xml/profile.xml was not found on this server.

The xml file is actually exists (tested with the direct URL) with all the folder and file permission set to 777. Any idea about what is missing?
Thanks in advance!
May 18 '07 #2

P: 6
I would suggest using relative URLs to start with, and if those work, begin working your way up to full pathnames for these files.
Thanks, Motoma!
The pdf issue is resolved by using the relative URL.

As I tried to apply same method to my second problem (xml), it doesn't seem to work. It returned me this error: Couldn't resolve host '..'

This is how I tried to read the content of the xml file:
[PHP]
$xmlSource= "../../../../myprofile.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$xmlSource);
[/PHP]

Could you give me any guidance?
Thanks a lot!!
May 21 '07 #3

pbmods
Expert 5K+
P: 5,821
This is how I tried to read the content of the xml file:
[PHP]
$xmlSource= "../../../../myprofile.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$xmlSource);
[/PHP]

Could you give me any guidance?
Thanks a lot!!
Try using file_get_contents instead.
May 21 '07 #4

P: 6
Try using file_get_contents instead.
Hi pbmods,

I had just tried with the function you suggested. It couldn't work as well.
I think the main problem I'm having here is that it couldn't find the file to read from, which I tried with either absolute URL or relative URL. What else can I do?
May 21 '07 #5

pbmods
Expert 5K+
P: 5,821
I think the main problem I'm having here is that it couldn't find the file to read from, which I tried with either absolute URL or relative URL. What else can I do?
Alrightey. Here's what I would do:
  • Create a PHP file in the same directory as the XML file you're trying to access.
  • Set the contents of that PHP file to:
    Expand|Select|Wrap|Line Numbers
    1. <?php echo __FILE__; ?>
  • Run the script.
  • Whatever it outputs, copy that and use that as the argument for file_get_contents (or what_have_you).
  • Change the path filename to match your XML file.

If that don't work, It's time to accelerate your server...

... at 9.8m/s^2.
May 21 '07 #6

P: 6
Alrightey. Here's what I would do:
  • Create a PHP file in the same directory as the XML file you're trying to access.
  • Set the contents of that PHP file to:
    Expand|Select|Wrap|Line Numbers
    1. <?php echo __FILE__; ?>
  • Run the script.
  • Whatever it outputs, copy that and use that as the argument for file_get_contents (or what_have_you).
  • Change the path filename to match your XML file.

If that don't work, It's time to accelerate your server...

... at 9.8m/s^2.
Wow, it works!
Now, I'm using file_get_contents instead of CURL; and document_root instead of URL.
A strange situation it is. The server just doesn't understand the "http://www.mywebsite.com".
Anyway, thank you very much for your help! Really appreciate it! =)
May 21 '07 #7

pbmods
Expert 5K+
P: 5,821
Really appreciate it! =)
No prob. Keep it comin' :)
May 21 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.