Warning: file archive function does not work

The following code:

<?php
$filevar = "/images/staunton/{$options_item['base_var']}.gif";

if(filesize($filevar) > 1616){
    $setstatus = "enabled";
}
else{
    $setstatus = "disabled";
}       
?>

Results in:

Warning: filesize() [function.filesize]: stat failed for /images/staunton/3-25.gif in [Originating PHPFILE(Edited)] on line 24

The path is the correct file .... my hosting server is running php 5.2 - is this a syntax error? I watched similar code and it looks correct.

+3
source share
1 answer

Instead of this:

$filevar = "/images/staunton/{$options_item['base_var']}.gif";

you probably want:

$filevar = $_SERVER["DOCUMENT_ROOT"] . "/images/staunton/{$options_item['base_var']}.gif";

because you probably confused the relative path of your image inside the root document of your page compared to the absolute path of the image in the file system.

Try and comment.

+9
source

All Articles