Welcome Guest, Not a member yet? Register   Sign In
uploading picture
#1

(This post was last modified: 08-09-2016, 01:26 AM by davy_yg.)

I need someone to help me fix this error message:

404 Page Not Found
The page you requested was not found.

After uploading picture and press upload it carries me to this :


views/addslideshows.php


PHP Code:
<td>
                <
div style="margin-left: 80px;">
 
               <div class="row">
                <
br><br>
                
 
                   <div class="col-md-12">
                        <
label for="filename" class="control-label">Select File to Upload</label
 
                   </div>
 
               </div>
                                
                <
div class="form-group">
 
               <div class="row">
 
                   <div class="col-md-12">
 
                       <input type="file" name="filename" size="20" />
 
                       <span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
                    </div>
                </div>
                </div>
            
                <div class="form-group">
                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="edit" value="Upload File" class="btn btn-primary"/>
                        </div>
                    </div>
                </div>
                </div>
            <?php /* </div> */ ?>
            </td> 



controllers/cuploadfile.php


PHP Code:
function upload()
 
   {
 
       //set preferences
 
       $config['upload_path'] = 'uploads/';
 
       $config['allowed_types'] = 'jpg|gif';
 
       $config['max_size'   '500000';

 
       //load upload class library
 
       $this->load->library('upload'$config);

 
       if (!$this->upload->do_upload('filename'))
 
       {
 
           
            
// case - failure
 
           $upload_error = array('error' => $this->upload->display_errors());
 
           // $this->load->view('upload_file_view', $upload_error);
            
$this->load->view('addslideshows'$upload_error);
 
       }
 
       else
        
{
 
           
            
// case - success
 
           $upload_data $this->upload->data(); 
 
           $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
 
           // $this->load->view('upload_file_view', $data);
            
            
$this->Mpages->add_slideshow();
            
            
$this->load->view('addslideshows'$data);
                        
 
       }
        
                
 
   

Can anyone help me figure this thing out?
" If I looks more intelligence please increase my reputation."
Reply
#2

I add this to routes.  Can anyone help me fix this error message:


routes.php

PHP Code:
$route['cuploadfile/upload_galleries/addslideshows'] = 'cloadfile/upload_galleries'
" If I looks more intelligence please increase my reputation."
Reply
#3

hello,
must use it into a form , you put it without form and direction for the action after submission.
read a documentation about upload library .
Reply
#4

(08-18-2016, 08:31 PM)davy_yg Wrote: I add this to routes.  Can anyone help me fix this error message:


routes.php

PHP Code:
$route['cuploadfile/upload_galleries/addslideshows'] = 'cloadfile/upload_galleries'

I do not see and form multipart any where use form helper

http://www.codeigniter.com/user_guide/he..._multipart

On controller __construct area load helper or autoload it and then on view

echo form_open_multipart('controller/function')

echo form_close()

Note: Make sure you set your base url.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#5

I wonder why this error still appears:

http://127.0.0.1/CompanyGiondaCI/index.p...ile/upload

404 Page Not Found
The page you requested was not found.


------------------------------------------------------------------

config/config.php


PHP Code:
$config['base_url'] = 'http://127.0.0.1/CompanyGiondaCI'



views/addslideshows.php

PHP Code:
<legend>CodeIgniter File Upload Demo</legend><br>
 
       <?php echo form_open_multipart('uploadfile/upload');?>
        
        <label><b>PHOTO GALLERY 1</b></label><br><br>
        
        <fieldset>
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label for="filename" class="control-label">Select File to Upload</label> 
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <input type="file" name="filename" size="20" />
                        <span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <input type="submit" value="Upload File" class="btn btn-primary"/>
                    </div>
                </div>
            </div>
        </fieldset> 



controllers/Cuploadfile.php

PHP Code:
<?php



class uploadfile extends CI_Controller {

 
   function __construct()
 
   {
 
       parent::__construct();
 
       $this->load->helper(array('form''url'));
 
   }

 
   //index function
 
   function index()
 
   {
 
       //load file upload form
 
       $this->load->view('addslideshows');
 
   }

 
   //file upload function
 
   function upload()
 
   {
 
       //set preferences
 
       $config['upload_path'] = 'uploads/';
 
       $config['allowed_types'] = 'jpg|gif';
 
       $config['max_size'   '500000';

 
       //load upload class library
 
       $this->load->library('upload'$config);

 
       if (!$this->upload->do_upload('filename'))
 
       {
 
           // case - failure
 
           $upload_error = array('error' => $this->upload->display_errors());
 
           $this->load->view('addslideshows'$upload_error);
 
       }
 
       else
        
{
 
           // case - success
 
           $upload_data $this->upload->data();
 
           $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
 
           $this->load->view('addslideshows'$data);
 
       }
 
   }
}


?>
" If I looks more intelligence please increase my reputation."
Reply
#6

Your "bad" link (http://127.0.0.1/CompanyGiondaCI/index.p...ile/upload) refers to "Cuploadfile", not to "uploadfile".
Where does the extra "C" come from?
Why didn't you notice this?
Reply
#7

404 Page Not Found
The page you requested was not found.


controllers/Cuploadfile.php


PHP Code:
//file upload function
 
   function upload()
 
   {
 
       //set preferences
 
       $config['upload_path'] = 'uploads/';
 
       $config['allowed_types'] = 'jpg|gif';
 
       $config['max_size'   '500000';

 
       //load upload class library
 
       $this->load->library('upload'$config);

 
       if (!$this->upload->do_upload('filename'))
 
       {
 
           // case - failure
 
           $upload_error = array('error' => $this->upload->display_errors());
 
           $this->load->view('addslideshows'$upload_error);
 
       }
 
       else
        
{
 
           // case - success
 
           $upload_data $this->upload->data();
 
           $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
 
           $this->load->view('addslideshows'$data);
 
       }
 
   



config/routes.php


PHP Code:
$route['Cuploadfile/upload'] = 'Cuploadfile/upload'
" If I looks more intelligence please increase my reputation."
Reply
#8

Obviously you will get 404 errors:

your form :


PHP Code:
echo form_open_multipart('uploadfile/upload'); 

Your controller: controllers/Cuploadfile.php

Your route (pointless code anyway and wrong):


PHP Code:
$route['cuploadfile/upload_galleries/addslideshows'] = 'cloadfile/upload_galleries'

Remove the route.
change the form_open.. to point to the controller/method 'cuploadfile/upload'

That should get you on the right path.

Also do yourself (and everyone else here) a favour:
Do these in order:
Learn English
Learn to listen
Learn Logic
Learn PHP
Learn MySQL
Then come back
A good decision is based on knowledge and not on numbers. - Plato

Reply
#9

(This post was last modified: 08-29-2016, 05:27 AM by InsiteFX.)

He's also missing the ending slash on the config base_url

This is also wrong:

PHP Code:
$config['upload_path'] = 'uploads/'

Should be:

PHP Code:
$config['upload_path'] = './uploads/'
If he read the CI Documentation he would know this...
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

Okay, I change something:


config/config.php



PHP Code:
$config['base_url'] = 'http://127.0.0.1/CompanyGiondaCI/'


controllers/Cuploadfile.php
  
PHP Code:
  //file upload function
    function upload()
    {
        //set preferences
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'jpg|gif';
        $config['max_size']    '500000';

        //load upload class library
        $this->load->library('upload'$config);

        if (!$this->upload->do_upload('filename'))
        {
            // case - failure
            $upload_error = array('error' => $this->upload->display_errors());
            $this->load->view('addslideshows'$upload_error);
        }
        else
        {
            // case - success
            $upload_data $this->upload->data();
            $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
            $this->load->view('addslideshows'$data);
        }
    


I still receiving this error messages:

404 Page Not Found
The page you requested was not found.
" If I looks more intelligence please increase my reputation."
Reply




Theme © iAndrew 2016 - Forum software by © MyBB