开发者

php file error. silly small problem

works fine on开发者_高级运维 the desktop with xampp but when i upload it to my webhost it doesnt. The file x.csv is in the same dir

$csv_file = "x.csv";

$handle = fopen(($csv_file), "r");

the error i get is-

fopen(x.csv): failed to open stream: No such file or directory in /var/www/html/x/admin/import_one.php on line 12

Where am I going wrong?


check that you have reading permissions for x.csv also try

$handle = fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . $csv_file, 'r'); 
(maybe your cwd isn't in the same directory)


Linux is case-sensitive, Windows isn't.

Make sure that your file is called x.csv and not X.csv or x.CSV.


When in doubt use absolute file path.

$path = '/path/dir/something/';
$file = 'x.csv';

$fp = fopen($path . $file, 'r');
if ($fp)
{ 
    // do some amazing stuff here.
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜