Reputation: 11
I try to guard a file, which I save from a form, in a path I specify. I use file_directory_path that returns the path to default, what do i do to change the path or to modify it to personalize it?
Code that this done but it does not function
$filepath='/sites/ficheros_profesores';
// str_replace(file_directory_path(),'',$filepath);
$file = file_save_upload('test',null,file_directory_path());
file_set_status($file, FILE_STATUS_PERMANENT);
Thanks
Upvotes: 1
Views: 75
Reputation: 77
If I properly understood, you are trying to save the uploaded file in a folder which is inside the default 'files' directory, isn't it?
Instead str_replace, you could concatenate the strings with '.'. Simply:
$file = file_save_upload('test',null,file_directory_path().'/sites/ficheros_profesores');
You should then ensure that the '/sites/ficheros_profesores/' exists and that the 'www-data' user (asuming linux) has the proper permissions.
Hope it helps.
Upvotes: 2