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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stephcsh
    New Member
    • May 2007
    • 6

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

    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.getima gesize]: 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!
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    I would suggest using relative URLs to start with, and if those work, begin working your way up to full pathnames for these files.

    Originally posted by stephcsh
    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.getima gesize]: 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!

    Comment

    • stephcsh
      New Member
      • May 2007
      • 6

      #3
      Originally posted by Motoma
      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,$xm lSource);
      [/PHP]

      Could you give me any guidance?
      Thanks a lot!!

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Originally posted by stephcsh
        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,$xm lSource);
        [/PHP]

        Could you give me any guidance?
        Thanks a lot!!
        Try using file_get_conten ts instead.

        Comment

        • stephcsh
          New Member
          • May 2007
          • 6

          #5
          Originally posted by pbmods
          Try using file_get_conten ts 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?

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Originally posted by stephcsh
            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:[code=php]<?php echo __FILE__; ?>[/code]
            • Run the script.
            • Whatever it outputs, copy that and use that as the argument for file_get_conten ts (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.

            Comment

            • stephcsh
              New Member
              • May 2007
              • 6

              #7
              Originally posted by pbmods
              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:[code=php]<?php echo __FILE__; ?>[/code]
              • Run the script.
              • Whatever it outputs, copy that and use that as the argument for file_get_conten ts (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_conten ts instead of CURL; and document_root instead of URL.
              A strange situation it is. The server just doesn't understand the "http://www.mywebsite.c om".
              Anyway, thank you very much for your help! Really appreciate it! =)

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Originally posted by stephcsh
                Really appreciate it! =)
                No prob. Keep it comin' :)

                Comment

                Working...