PHP force download, download without naming the file the full path name -


so our system works storing user images in in user folders, user folders stored in master user folders stored in 1 folder called client_folders.

everytime try build our download script (using php force download) files downloaded name of entire file path

example: client_folder/user_30/client_130/image.jpg

i want file image.jpg

i have tried several things, explode array pop, basename() everytime try 1 of these options variable readfile() function reads empty.

now in mysql storing entire file path (file name included) in 1 column, right way this? , how download files without entire path

if helps code downloads....just full path name :(

ob_clean(); if(isset($_post['file_name'])){ $file = $_post['file_name']; header("content-type: application/octet-stream"); header('content-disposition: attachment; filename="'.$file.'"'); readfile($file); exit(); } 

in readfile have pass full path, in header in filename file name user:

ob_clean(); if(isset($_post['file_name'])){ $file_for_user = $_post['file_name']; $full_path_file = "storage_path".$file_for_user; header("content-type: application/octet-stream"); header('content-disposition: attachment; filename="'.$file_for_user.'"'); readfile($full_path_file); exit(); } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -