Let's look at how the user uploads an image. The following is the sequence of events:
CodeIgniter looks in the
routes.php
config file and finds the following line:$route['create'] = "create/index";
It directs the request to the
create
controller'sindex()
function.The
index()
function loads thecreate/create.php
view file that displays the upload form to the user.The user clicks on the Choose file button, navigates to the image file they wish to upload, and selects it.
The user presses the Upload button and the form is submitted to the
create
controller'sindex()
function.The
index()
function creates a folder in the mainupload
directory to store the image in, then does the actual upload.On a successful upload,
index()
sends the details of the upload (the new folder name and image name) to thesave_image()
model function.The
save_model()
function also creates a unique code and saves it in theimages
table along with the folder name and image name passed to it by the...