Lassie Posted January 18, 2007 Share Posted January 18, 2007 I am trying to build a download that needs to establish a filepath.There is a download dir which holds a hash folder, which holds the files.I can get as far as indentifying the files but I cant seem to attach the file name to the dir/hash path.How can i capture the file name?[code]//open the dir $folder= opendir("C:pick_up/$hash"); //check if dir opened - to be done // prepare the download //loop through the directory while($file = readdir($folder)) { if($file !='.'&& $file != '..') echo "$file<br>"; } closedir($folder); $filepath = 'C:/pick_up/$hash/'.$file;//doen't attach file name and ext echo"$filepath";// check that it exists and is readable if (file_exists($filepath) && is_readable($filepath)) {// get the file's size and send the appropriate headers $size = filesize($filepath); header('Content-Type: application/octet-stream'); header('Content-Length: '.$size); header('Content-Disposition: attachment; filename='.$file); header('Content-Transfer-Encoding: binary');// open the file in binary read-only mode $file = fopen($filepath, 'rb'); if ($file) {// stream the file and exit the script when complete fpassthru($file);exit; }else {echo "$nogo"; } } [/code] Link to comment https://forums.phpfreaks.com/topic/34727-setting-up-filepath/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.