CodeIgniter Upload File (CUF)

This problem occurred when I started a new project to add new features that uploaded image and audio files to my blog. Actually my program has run smoothly on a local server, but it doesn't work when I push it to my online blog master application.

I tried Google Fu in various directions, no exception stackoverflow, until finally it reached a dead end. Resolving this problem takes about 3 days with Google Fu techniques.

In the end I tried the last attempt by contacting the hosting provider for technical support, and it turns out "THIS IS THE SOLUTION", what's the full story? see the following summary.

What I Do Based on Googling / Google Fu Techniques?

1. I am Implementing CodeIgniter Technical Documentation

First, I create an upload folder and a thumbnails subfolder in the root directory

Then configure Autoload for the "upload" library and the helper "file", "directory" & "thumb_helper"

$autoload['libraries'] = array('upload','table','database','session','form_validation','email','ion_auth','markdown');

and

$autoload['helper'] = array('html','form','url','thumb_helper','directory','file');

Next, implement the  File Uploading Class documentation .

Actually, the steps so far have been able to work well on the local server to upload both image and audio files (in this case I uploaded mp3 & wav)

Unfortunately when I push this new feature to the master blog application that is online, upload always fails.

2. Add some types of mp3 audio collections in mimes.php

Before

'mp3' => array('audio/mpeg', 'audio/mpeg3', 'audio/mpg', 'audio/x-mpeg', 'audio/mp3'),

After

'mp3'   =>   array('audio/mpeg', 'audio/mpeg3', 'audio/mpg','audio/x-mpeg', 'audio/mp3', 'application/force-download', 'application/octet-stream'),

Unfortunately this is not a solution, uploading still fails.

3. Increase the limit of post_max_size & upload_max_filesize on php.ini

In this case I use two methods, namely via CPanel and via .htaccess

The CPanel method, choose "Select PHP Version" in the SOFTWARE category, click "Switch to PHP Options", here you can set both of them.

The .htaccess method You can add the following code (adjust to your needs!)

# Control php.ini
php_value upload_max_filesize 512M
php_value post_max_size 512M

Unfortunately this is not a solution, uploading still fails.

What is The Solution?

I contacted the technical support hosting provider and explained everything, what I had done regarding this problem, and the results are ...

This is the solution, and until right now, I don't know what he did, but the point is my problem is solved!

Fix CodeIgniter Class File Uploading Error on Online Server

This problem occurs when I start a new project to add a new feature, namely uploading images and audio files to my blog. Actually my program has been running smoothly on the local server, but it doesn't work when I push it to my online blog application master.

I tried to do Googe Fu / Googling to various corners, including stackoverflow, until finally hit a dead end. Solving this problem took about 3 days with the Google Fu technique.

Finally I tried the last resort by contacting the hosting provider's technical support, and it turns out THIS IS THE SOLUTION, what's the full story? see the following summary.

What do I do with the Googling / Google Fu technique?

1. I Implemented CodeIgniter Technical Documentation

First create an upload folder and a thumbnails subfolder inside the root directory.

Then, configure autoload for the "upload" library and the "file", "directory" & "thumb_helper" helpers.

$autoload['libraries'] = array('upload','table','database','session','form_validation','email','ion_auth','markdown');

And

$autoload['helper'] = array('html','form','url','thumb_helper','directory','file');

Next implement the  File Uploading Class documentation .

Actually, the steps so far have been able to work well on the local server to upload files, both images and audio (in this case I uploaded mp3 & wav)

Unfortunately when I push to the master blog application which is already online, the upload always fails.

2. Adding a collection of mp3 audio types in the mimes.php file

Before

'mp3' => array('audio/mpeg', 'audio/mpeg3', 'audio/mpg', 'audio/x-mpeg', 'audio/mp3'),

After

'mp3' =>   array('audio/mpeg', 'audio/mpeg3', 'audio/mpg','audio/x-mpeg', 'audio/mp3', 'application/force-download', 'application/octet-stream'),

Unfortunately this is also not a solution, upload still fails.

3. Increase post_max_size & upload_max_filesize limits in php.ini

In this case I use two methods, namely via CPanel and via .htaccess

CPanel method, select Select PHP Version in the SOFTWARE category, click Switch to PHP Options, there you can set both points.

.htaccess method You can add the following code (adjust to your needs!)

# Control php.ini
php_value upload_max_filesize 512M
php_value post_max_size 512M

Unfortunately this is also not a solution, upload still fails.

What is the solution?

I contacted the hosting provider's technical support and explained everything I had done regarding this issue, and the result was...

This was the solution, and to this day I have no idea what it did, but the point is my problem was solved!


Post a Comment

Previous Next

نموذج الاتصال