Media View in cakePHP -
hi implemented file download functionality in cakephp frame work using mediaview few reasons passed 1 parameter through url parameter displayed along file name need remove url parameter, tried failed please helop me.
my code downloading file
$fileextn = explode('.', $this->contentitem['file_path']); $url = $this->contentitem['file_path']; $urlarr = explode('/', $url); $fileextn = end($fileextn); if(in_array($fileextn, $this->mediamap)) { $fileextn = str_replace('.', '', $fileextn); if(!empty($urlarr)) { $filename = end($urlarr); $filenamewoextn = explode('.', $filename); //$filenamewoextn = $filename[0]; $filenamewoextn = $filename; unset($urlarr[count($urlarr)-1]); $url = implode(ds, $urlarr); } $this->view = 'media'; $params = array( 'id' => $filename, 'name' => $filenamewoextn, 'download' => false, 'extension' => $fileextn, // must lower case 'path' => app . 'views' . ds . 'static'. $url .ds // don't forget terminal 'ds' ); $this->set($params);
my url : /uploads/leave_policy_leave_policy_tasks_v1.3.xlsx
thanks in advance
you use regular expression last .
char, such
preg_match("/(.*?)(\.)(\w*)$/", $filepath, $path_parts);
you'll want leverage functionality of folder
, file
objects come cakephp.
Comments
Post a Comment