• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Upload Hell

#1
[eluser]Unknown[/eluser]
I've been learning CodeIgniter and applying it to our online store (northbreeze.com). It's been fantastic so far, and I'm currently generating a "Latest Additions" newsletter for subscribers.
I'd like to provide registered users with the ability to create their own pages with their own images. Everything is working except the file upload. No matter what I do I keep getting
"The upload path does not appear to be valid."
The paths I've tried are valid. The permissions are all set to 777.
Finally tried to upload using the scripts supplied in the User Guide and they don't work either. Same message. I don't see why an operation this basic should be so problematic. I've written file upload scripts in plain PHP and I suppose I can hook one of those up somehow, but it would be much better if I didn't have to.
FYI here are the scripts from the User Guide:

upload.php (only change has been to "$config['upload_path'] = './uploads/';"):
<?php

class Upload extends Controller {

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

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

function do_upload()
{
$config['upload_path'] = './uploads/'; // Only changes here
$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);
}
}
}
?>

upload_form.php (no changes):
<html>
<head>
<title>Upload Form</title>
</head>
<body>

<?php echo $error;?>

<?php echo form_open_multipart('upload/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

&lt;input type="submit" value="upload" /&gt;

&lt;/form&gt;

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

upload_success.php (no changes):
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Upload Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h3>Your file was successfully uploaded!</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;

Any help would be greatly appreciated, and thanks in advance

Peter Weicker
peterweicker@shaw.ca
-or-
info@northbreeze.com

#2
[eluser]crumpet[/eluser]
did you try using an explicit path like /home/myaccount/uploaddir ?

#3
[eluser]Unknown[/eluser]
yes i did, thanks. all kinds of them. also adapted a plain php script. that actually works, but i would prefer not having to step in and out of CI to get work done. one of the things i had enjoyed about using CI was a measure of relief from the oppressive fussiness of php.

#4
[eluser]crumpet[/eluser]
.. how about with no trailing slash..?

#5
[eluser]xwero[/eluser]
check the log for errors.

#6
[eluser]phpserver[/eluser]
Have you tried using an absolute path with a trailing slash at the end?.

/var/www/uploads/this_is_a_folder/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.