I am new here and have the below problem not getting the filesize.
I have the same problem with mimetype.

Anyone who can help solve my problem or explain why this happens?

RUNNING:
OS: Linux 2.6.37.1-1.2-desktop x86_64
SYSTEM: openSUSE 11.4 (x86_64)
PHP Ver: 5.3.5-5.12.1

  /*
    1 line in filesizetestfil.txt
    public://files/image/2ferie10.png
  */
  $inputlines = file('filesizetestfil.txt');
  foreach ($inputlines as $line_num => $line) {
    $fieldimage_dir = $line;
  }
  echo "fieldimage_dir = ".$fieldimage_dir."<br /><br />";

  // this do not work
  $fullpath1 = substr_replace($fieldimage_dir,'',0,9);
  echo "fullpath1 = ".$fullpath1."<br />";
  $filesize1 = filesize ($fullpath1);
  echo "filesize1 = ".$filesize1."<br /><br />";
  // this works echo "<img src='".$fullpath1."'><br />";

  // this work
  $fullpath2 = "files/image/2ferie10.png";
  echo "fullpath2 = ".$fullpath2."<br />";
  $filesize2 = filesize($fullpath2);
  echo "filesize2 = ".$filesize2."<br />"; 
  //this works echo "<img src='".$fullpath2."'><br />";

    "public://" isn't a protocol that PHP understands. Nor do I, for that matter.

    EDIT: Also, welcome to PHPBuilder! When posting PHP code, please use the board's [noparse]

    ..

    [/noparse] bbcode tags as they make your code much easier to read and analyze.

      the line starting with "$fullpath1" removes the "public://" so the variable $fullpath1 contains the same string as $fullpath2.

        What is the PHP error message generated by filesize() when it doesn't work?

          I am not sure how to write an exception handler for this.

            There's no need for an exception handler just to view the error message - just enable display_errors and set error_reporting to E_ALL.

            EDIT: Also, what is the value of $fullpath1 that causes filesize() not to work?

              Warning: filesize(): stat failed for files/image/2ferie10.png in /srv/www/htdocs/postnr/mimetest.php on line 24 filesize1 =

                string(25) "files/image/2ferie10.png "

                  cord1;10976976 wrote:

                  string(25) "files/image/2ferie10.png "

                  And there's your problem. Notice the end of the string?

                    $fullpath1 = substr_replace($fieldimage_dir,'',0,9);
                    $fullpath1 = trim($fullpath1);

                    solves the problem.

                    Thanks again and have a nice night!

                      cord1;10976980 wrote:

                      solved

                      You can mark this thread resolved (if it is) using the link on the Thread Tools menu above.

                        Write a Reply...