Welcome Guest, Not a member yet? Register   Sign In
Problem with Gallery Image Uploading
#1

[eluser]jshultz[/eluser]
I've got an image uploader that doesn't upload images. I'm not receiving any errors and i've checked the folder permissions and even on 777 no images are getting uploaded.

You can see the code here: http://pastebin.com/Wzu4gyed

The value for gallery_path is /home/domain/public_html/assets/images/gallery

The value for gallery_path_url is http://domain.com/assets/images/gallery/

I have used this same code on another site with zero problems. I'm not sure what the problem is with this site?

Here's the message I'm getting from var_dump:

Quote:The upload path does not appear to be valid. You did not select a file to upload. array(13) { ["file_name"]=> string(0) "" ["file_type"]=> string(0) "" ["file_path"]=> string(0) "" ["full_path"]=> string(0) "" ["raw_name"]=> string(0) "" ["orig_name"]=> string(0) "" ["file_ext"]=> string(0) "" ["file_size"]=> string(0) "" ["is_image"]=> bool(false) ["image_width"]=> string(0) "" ["image_height"]=> string(0) "" ["image_type"]=> string(0) "" ["image_size_str"]=> string(0) "" } string(48) "/home/verdebus/public_html/assets/images/gallery"

I checked the file extensions and they're correct. i've tried hardcoding the upload path, removing /home/verdebus from it and just using /public/html/assets/images/gallery and that didn't work. and i've tried it with and without a trailing slash. still no go.
#2

[eluser]jshultz[/eluser]
any ideas?
#3

[eluser]nzmike[/eluser]
Make sure all the directories in the path can be read/executed by whatever user runs your web server.
#4

[eluser]jshultz[/eluser]
i double checked that. The funny thing is that I am using the same code in another site and have had no problem. it's really perplexing me.
#5

[eluser]nzmike[/eluser]
I'm not sure if this is the problem but in your view you have:

Code:
form_upload(');

Which creates a file input with the name "userfile".

Later on you go onto do:

Code:
if(! $this->upload->do_upload(')){

Which will always be true if I'm not mistaken because "Filedata" will not be set.

I doubt this will fix it. The only other thing I can recommend is try simplifying your code a bit. Get rid of everything that isn't to do with uploading an image i.e. the resize you do at the end.

I've only briefly looked at the code but hopefully this will help you find your bug.
#6

[eluser]jshultz[/eluser]
I removed the extra code, still no go. Sad

[quote author="nzmike" date="1279687706"]I'm not sure if this is the problem but in your view you have:

Code:
form_upload(');

Which creates a file input with the name "userfile".

Later on you go onto do:

Code:
if(! $this->upload->do_upload(')){

Which will always be true if I'm not mistaken because "Filedata" will not be set.

I doubt this will fix it. The only other thing I can recommend is try simplifying your code a bit. Get rid of everything that isn't to do with uploading an image i.e. the resize you do at the end.

I've only briefly looked at the code but hopefully this will help you find your bug.[/quote]
#7

[eluser]jshultz[/eluser]
[quote author="crusher machine" date="1279867917"]Make sure all the directories in the path can be read/executed by whatever user runs your web server. cone crusher[/quote]

That's been done, too. It's the same server as I'm using for other websites. I'm using the same code on another site on the server to do the same thing without any problems. That's why this has been such a perplexing situation.
#8

[eluser]jshultz[/eluser]
Ok, I've cleaned up the code to the point that I'm basically copying the user guide. Here's what I have:


Here's the Upload Function:

Code:
function do_upload() {

        $this->load->helper(array('form', 'url'));
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg';
        $config['max_size']    = '2000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();


    if ( ! $this->upload->do_upload())
            {
                $this->load->model('Gallery_model');

                $error = array('error' => $this->upload->display_errors());
                echo var_dump($error);
                $upload_info = $this->upload->data();
                echo var_dump($upload_info);

                $data['gallery_path'] = $this->gallery_path;
                $data['gallery_path_url'] = $this->gallery_path_url;
                
                $data['images'] = $this->Gallery_model->get_images();
                $data['page_title'] = 'Verde Valley Business Resource - Gallery Manager';
                $data['page'] = '/ads/gallery_view'; // pass the actual view to use as a parameter
                $this->load->view('container',$data);
            }    
            else
            {
                $data = array('upload_data' => $this->upload->data());
                
                $this->load->view('upload_success', $data);
            }
    }



Here's the view:

Code:
<div class="span-24">
<div class="span-6">&lt;?php include('about-include.php'); ?&gt;</div>

<div class="span-16 prepend-1">
    <h2>Welcome to the Ad Manager!</h2>

    &lt;?php
        
        echo $gallery_path; echo '<br/>';
        echo $gallery_path_url;
        
    ?&gt;
  
  <div id="gallery">
        &lt;?php if (isset($images) && count($images)):
            foreach($images as $image):    ?&gt;
            <div class="thumb">
                <a href="&lt;?php echo $image['url']; ?&gt;">
                    <img src="&lt;?php echo $image['thumb_url']; ?&gt;" />
                </a>                
            </div>
        &lt;?php endforeach; else: ?&gt;
            <div id="blank_gallery">Please Upload an Image</div>
        &lt;?php endif; ?&gt;
</div>
    
<div id="upload">
        &lt;?php
        echo form_open_multipart('/gallery/do_upload');
echo form_hidden('redirect', '/gallery/index');
        echo form_upload('userfile');
        echo form_submit('upload', 'Upload');
        echo form_close();
        ?&gt;        
    </div>
    
</div>
</div>


I'm not even messing with a model.

When I upload a file, it's still not going into the folder. I've tried different ways for formatting the path. I've made sure that the folder is 777. Here's the errors that I'm getting back:

array(1) { ["error"]=> string(102) "
The upload path does not appear to be valid.

The upload path does not appear to be valid.

" } array(13) { ["file_name"]=> string(0) "" ["file_type"]=> string(0) "" ["file_path"]=> string(0) "" ["full_path"]=> string(0) "" ["raw_name"]=> string(0) "" ["orig_name"]=> string(0) "" ["file_ext"]=> string(0) "" ["file_size"]=> string(0) "" ["is_image"]=> bool(false) ["image_width"]=> string(0) "" ["image_height"]=> string(0) "" ["image_type"]=> string(0) "" ["image_size_str"]=> string(0) "" }


Any ideas?
#9

[eluser]jshultz[/eluser]
Ok, I'm still fighting with this. I've worked on the controller some more, trying to do some troubleshooting. Here's the new rewrote controller:
Code:
&lt;?php
class Gallery extends Controller {

    function __construct()
        {
            parent::__construct();
    
            $this->gallery_path = realpath(APPPATH . '../uploads');
            $this->gallery_path_url = base_url().'uploads';
        }
    
    function index() {

        
        $this->load->model('Gallery_model');
        
        if ($this->input->post('upload')) {
            

        }
        
        $data['gallery_path'] = $this->gallery_path;
        $data['gallery_path_url'] = $this->gallery_path_url;
        
        $data['images'] = $this->Gallery_model->get_images();
        $data['page_title'] = 'Verde Valley Business Resource - Gallery Manager';
        $data['page'] = '/ads/gallery_view'; // pass the actual view to use as a parameter
        $this->load->view('container',$data);
        
    }

    function do_upload() {

        $this->load->helper(array('form', 'url'));
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg';
        $config['max_size']    = '2000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();


    if ( ! $this->upload->do_upload())
            {
                $this->load->model('Gallery_model');
$this->load->helper(array('form', 'url'));

                $upload_info = $this->upload->data();

                $data['gallery_path'] = $this->gallery_path;
                $data['gallery_path_url'] = $this->gallery_path_url;
                $data['error'] = $this->upload->display_errors('<p class="error">', '</p>');
                $data['upload_data'] = array('upload_data' => $this->upload->data());
                $data['images'] = $this->Gallery_model->get_images();
                $data['page_title'] = 'Verde Valley Business Resource - Gallery Manager';
                $data['page'] = '/ads/gallery_view'; // pass the actual view to use as a parameter
                $this->load->view('container',$data);
            }    
            else
            {
                $data = array('upload_data' => $this->upload->data());
                
                $this->load->view('upload_success', $data);
            }
    }

    
}

And the View:
Code:
<div class="span-24">
<div class="span-6">&lt;?php include('about-include.php'); ?&gt;</div>

<div class="span-16 prepend-1">
    <h2>Welcome to the Ad Manager!</h2>

    &lt;?php
        
        echo $gallery_path; echo '<br/>';
        echo $gallery_path_url;
        
    ?&gt;
  
  
  <div id="gallery">
        &lt;?php if (isset($images) && count($images)):
            foreach($images as $image):    ?&gt;
            <div class="thumb">
                <a href="&lt;?php echo $image['url']; ?&gt;">
                    <img src="&lt;?php echo $image['thumb_url']; ?&gt;" />
                </a>                
            </div>
        &lt;?php endforeach; else: ?&gt;
            <div id="blank_gallery">Please Upload an Image</div>
        &lt;?php endif; ?&gt;
</div>
    
<div id="upload">
        &lt;?php
        echo form_open_multipart('/gallery/do_upload');
echo form_hidden('redirect', '/gallery/index');
        echo form_upload('userfile');
        echo form_submit('upload', 'Upload');
        echo form_close();
        ?&gt;        
    </div>
    &lt;?php echo $error;?&gt;

&lt;?php echo($data['upload_data']['file_name']."<br />");
    echo($data['upload_data']['image_width']." px<br />");
    echo($data['upload_data']['image_height']." px");
?&gt;

    &lt;?php if (isset($upload_data) && count($upload_data)):
        foreach ($upload_data as $upload): ?&gt;
            <p class="notice">&lt;?php echo $upload['file_name']; ?&gt;</p>
            <p class="notice">&lt;?php echo $upload['file_path']; ?&gt;</p>
            <p class="notice">&lt;?php echo $upload['full_path']; ?&gt;</p>
            <p class="notice">&lt;?php echo $upload['raw_name']; ?&gt;</p>
            &lt;?php endforeach; else: ?&gt;
    <p class="notice">No Data</p>
        &lt;?php endif; ?&gt;
</div>
</div>

Just to clarify about the paths. If you FTP to the server, this is what the path to the upload directory look like: /public_html/uploads

gallery_path is: /home/verdebus/public_html/uploads

and gallery_path_url is http://vvbusinessresource.com/uploads/

i've tried various ways of hardcoding the path into the variable but I consistently get "The upload path does not appear to be valid." in the error.

I have three other sites on the server where uploading files has not been a problem. I just don't know why I'm having a problem this time. Sad




Theme © iAndrew 2016 - Forum software by © MyBB