Sam Sahakian
Sam Sahakian

Reputation: 13

php fopen can't find file that definitely exists

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 file or directory

The file definitely exists, and I get the same problem on Unix machines. How do I fix this?

Upvotes: 1

Views: 3452

Answers (1)

cwallenpoole
cwallenpoole

Reputation: 81998

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.

Upvotes: 2

Related Questions