Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is my test code:
i just create a text file and store on server folder name"image".it stored on folder
but when i try to read or check using url but file not exist return from if condition.
all the permission are set to read and write of image folder
so please solve my problem.

PHP
<?php

        $FileName="/home/a/public_html/image/"."image_".rand().".txt";
    $binary="hello";
    $Event_file = fopen($FileName, "wb");
    fwrite($Event_file, $binary);
    fclose($Event_file);
    $Path=realpath($FileName);
        echo "path".$Path."<br>";
 //get image file
    $get_path="http://www.myapp.net/image/image_654391973.txt";
echo $get_path ."<br>";
   if(is_file($get_path))
{
echo "file exists on server";
}
else
{
echo "file not exists on server ";
}
?>
Posted
Updated 19-Apr-14 6:29am
v3

1 solution

You should rely only on the URL of your file (relative to the root directory configured for your site). When you need a file name in the file system of your host computer, you can get it using MapPath:
http://msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900