file uploading |
Hello,
I am new to coding world and using CI4.4.6 I followed the manual about file uploading and I successfully made the link to force file downloaded via web browser. One problem I encountered is the how can I link to the mp3 file. I made <audio><source src=""></audio> but it didn't play the mp3 file. I researched and found some solution; 1. I have to move 'WRITEPATH . 'uploads/' directory to '/public' because /public directory is able to be accessed via web. Here is a question. If my understanding is right, how can I change the directory from '/writable' to '/public' ? Here is my code in Controller. PHP Code: $userfile = $this->request->getFile('userfile'); even though tried below the result is same strangely. File is still stored in writable directory !!!! PHP Code: $userfile = $this->request->getFile('userfile');
Read https://codeigniter.com/user_guide/libra...tore-files
The following code is a bit difficult to understand, but $img->store() moves the file. PHP Code: if (! $img->hasMoved()) {
According to my understanding, $file->store() is CI4's function which only works for WRITEPATH. With store(), I can only modify the folder under the WRITEPATH.
So I use $file->move() to save uploaded file and set the directory '/public' manually. After saving uploaded files in '/public', I can link mp3 file in audio tag. |
Welcome Guest, Not a member yet? Register Sign In |