Welcome Guest, Not a member yet? Register   Sign In
File not uploading live hosting. help? :)

(This post was last modified: 10-07-2023, 07:44 AM by xsPurX.)

I had this working fine on localhost, but since I put the folder structure outside public_html, I had to change the path to the upload directory. So I made a writable/uploads folder in public_html. The problem is it doesn't seem to upload, and my database just gives fillled with only part of the file path, with no filename. Sorry for all the posts, I'm used to CI2. and been away for awhile. so I skipped CI3. and a lot has changed!
PHP Code:
rules = [
                    'name' => 'required|max_length[100]',
                    'userfile' => [
                        'label' => 'Image File',
                        'rules' => [
            if (! $this->validate($rules))
                $request = \Config\Services::request();
                $this->data['error'] = ['errors' => $this->validator->getErrors()];
                $this->data['heading'] = 'Add Article';
                $this->data['layouts'] = $this->PageAdminModel->get_layouts();
                $this->data['categories'] = $this->BlogAdminModel->get_categories();
                $this->data['groups'] = $this->PageAdminModel->get_groups();
                $this->data['w_locations'] = $this->PageAdminModel->get_widget_locations();
                $page_container 'layout_blank';
                $template_path '/themes/admin/layouts/';
                $layout $template_path$page_container;
                $this->data['page'] = $template_path '/BlogAdmin/addarticle';
                return view($layout$this->data);
                $request = \Config\Services::request();
                $img $this->request->getFile('userfile');
                if($img == '')
                    $file '';
                    if (! $img->hasMoved()) 
                        $filepath $_SERVER['DOCUMENT_ROOT'] . '/writable/uploads/' $img->store();

                        $userfile = ['uploaded_fileinfo' => new File($filepath)];
                        $file_name explode ('/'$userfile['uploaded_fileinfo']);
                        $file $file_name[1] . '/' $file_name[2];
= [
                    'name' => strip_tags($this->request->getPost('name')),
                    'url_name' => strip_tags(url_title($this->request->getPost('name'))),
                    'text' => $this->request->getPost('text'),
                    'userfile' => $file,
                    'container_name' => $this->request->getPost('container_name'),
                    'active' => $this->request->getPost('active'),

Edit.... now it is somehow uploading the files to the directory above public-html. I don't understand why its uploading there, cause I have the correct path listed above. Somehow ci is saving the files in an unaccessable folder.. Any ideas?

I had to do this below. it works. Smile

PHP Code:
filepath = $img->store('../../../public_html/writable/uploads/'); 

Messages In This Thread
File not uploading live hosting. help? :) - by xsPurX - 10-07-2023, 06:59 AM

Theme © iAndrew 2016 - Forum software by © MyBB