Saturday, November 14, 2015

failed to open stream: No such file or directory

http://stackoverflow.com/questions/16934912/failed-to-open-stream-no-such-file-or-directory

Can anyone help with this one? I am new to web developing and not sure what this error means?
Warning: fopen(images/nophoto.png): failed to open stream: No such file or directory in /home/u835626360/public_html/remove.html on line 101
can't this file/picture is open you need close
CODE:
$expire=time()-3600;
setcookie("dname","a", $expire);
setcookie("dpode","a", $expire);
}
function delpics($filename)
{
$path_to_file='userpics/';
$old = getcwd(); // Save the current directory
    chdir($path_to_file);
    $fh = fopen($filename, 'w') or die("can't this file/picture is open you need close ");
    fclose($fh);
    if (!unlink($filename))
  {
  echo ("Error deleting $file");
  }
else
  {
  echo ("Deleted  $filename");
  }
    chdir($old); // Restore the old working directory   
}
shareimprove this question

    
it said, file not found – Raptor Jun 5 '13 at 8:25
    
Can you at least post the full path to the image file ? – Jerska Jun 5 '13 at 8:28
    
sorry what does this mean? – user2149630 Jun 5 '13 at 11:49

3 Answers

You need to give fopen the full path of the file, and you don't need chdir() at all. Try this version:
$path_to_file='userpics/';
$fh = fopen($path_to_file.$filename, 'w') or die('Permission error');
shareimprove this answer