Welcome Guest, Not a member yet? Register   Sign In
Tutorial File Upload Class Problem
#1

[eluser]davehedgehog[/eluser]
Okā€¦same area, new problem was wondering if you guys could help.

Basically I cant upload the file and keep getting 404

I have configured the Url etc. and think it reads right like this:


www.####.com/upload/do_upload

Now my route config file reads:

Code:
$route['upload/upload_success'] = 'upload/upload_success';
$route['upload'] = 'upload';

My View is slightly different from the tutorial to allow me to browser folders.

Code:
<html>
<head>
<title>Upload Form</title>
</head>
<body>

<?php echo $error;?>

<div id="upload">
&lt;?php
echo form_open_multipart('upload/do_upload');
echo form_upload('userfile');
echo form_submit('upload', 'Upload');
echo form_close();
?&gt;  
</div>
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

oh and the Success view

Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Upload Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h3> Your file uploaded successfully!</h3>

<ul>

&lt;?php foreach ($upload_data as $item => $value):?&gt;
<li>&lt;?php echo $item;?&gt;: &lt;?php echo $value;?&gt;</li>
&lt;?php endforeach;?&gt;
</ul>

<p>&lt;?php echo anchor('upload', 'Upload another file!');?&gt;</p>


&lt;/body&gt;
&lt;/html&gt;

And the Controller file:

Code:
&lt;?php

class Upload extends CI_Controller {

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

function index()
{
  $this->load->view('upload_form', array('error' => ' ' ));
}

function do_upload()
{
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '100';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

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

  if ( ! $this->upload->do_upload())
  {
   $error = array('error' => $this->upload->display_errors());

   $this->load->view('upload_form', $error);
  }
  else
  {
   $data = array('upload_data' => $this->upload->data());

   $this->load->view('upload_success', $data);
  }
}
}
?&gt;

I have also set the uploads folder at the root with permissions set to 0777, Ive been tinkering with different options most of the day and still baffled by the 404 =S

Any help?
#2

[eluser]TheFuzzy0ne[/eluser]
This is a duplicate of this post http://ellislab.com/forums/viewthread/234301/#1050468. Please do not reply to this thread.

Please don't double-post. It makes it more difficult to help you, and it will result in people not wanting to help you.
#3

[eluser]davehedgehog[/eluser]
Oh my bad sorry, wanted to make sure I asked you two that previously commented also oh as well as distinguish betweent the different problems




Theme © iAndrew 2016 - Forum software by © MyBB