Sunday, 18 August 2013

Getting warning in download.php file

Getting warning in download.php file

I am running this file:
$file_name = "WEL_log_".date('Y_m');
$url = 'http://www.welserver.com/WEL0521/'.$file_name.'.xls';
$base_path = '/Applications/XAMPP/xamppfiles/htdocs/website/';
$tmp_path = $base_path.'tmp_'.$file_name.'.tsv';
$path = $base_path.$file_name.'.tsv';
$current_month_path = $base_path.'current_month.tsv';
$latest_path = $base_path.'latest.tsv';
function downloadFile ($url, $path) {
global $latest_path;
global $tmp_path;
global $current_month_path;
global $base_path;
$newfname = $tmp_path;
$file = fopen ($url, "rb");
if ($file) {
The line below is line 37 in coding:
$newf = fopen ($newfname, "wb");
if ($newf){
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
}
}
}
if ($file) {
fclose($file);
}
if ($newf) {
copy($tmp_path, $current_month_path);
rename($tmp_path, $path);
fclose($newf);
write_latest_data($path, $latest_path);
}
}
function write_latest_data($read_file_path, $write_file_path,
$no_of_new_lines=10){
$file = file($read_file_path);
$write_f = fopen ($write_file_path, "wb");
$line_count = count($file) > $no_of_new_lines ? $no_of_new_lines :
count($file);
if ($write_f){
fwrite($write_f, $file[0], 1024 * 8 );
$file = array_reverse($file);
for($i=0; $i < $line_count; $i++){
fwrite($write_f, $file[$i], 1024 * 8 );
}
fclose($write_f);
}
and getting this warning
Warning:
fopen(/Applications/XAMPP/xamppfiles/htdocs/website/tmp_WEL_log_2013_08.tsv):
failed to open stream: Permission denied in
/Applications/XAMPP/xamppfiles/htdocs/website/download.php on line 37
Please tell me what am I doing wrong?

No comments:

Post a Comment