I'm trying to load data from a CSV on my Windows PC into a database, something I've successfully done previously. fopen
can't find my input file.
Here's the specific code I'm having trouble with:
<?php
ini_set('track_errors', '1');
$handle = fopen("C:/Users/Sam/Documents/test.csv", 'r') or die("can't open file: $php_errormsg");
?>
The error printed is:
[function.fopen]: failed to open stream: No such f开发者_如何学Goile or directory
The file definitely exists, and I get the same problem on Unix machines. How do I fix this?
Windows 7 (and Vista?) only lets a user access his own home directory and does not allow Apache (or other users) to. Unfortunately, this is a major headache, and I would suggest that you just move the file somewhere public.
This type of behavior is easier to fix in Linux, but you're still better off moving the file out of your directory into some path where Apache has read access.
精彩评论