Welcome Guest, Not a member yet? Register   Sign In
file upload issue [RESOLVED]
#1

[eluser]gafroninja[/eluser]
Hey Guys,

Yup you've guessed it, I have an issue with the file upload class. I'm sorry to bother people about it, but I feel I'm missing something and can't for the life of me figure it out. I've set the folders chmod 777.

view:
Code:
<?= form_open_multipart('admin/page_update/'); ?>
        
        <fieldset>
            <h3>Page Content</h3>
            <p>
                <label for="userfile">Main Image</label>
                &lt;input type="file" name="userfile" size="20" /&gt;
            </p>
            
        </fieldset>
        
        <p>
            &lt;input type="submit" value="upload" /&gt;
        </p>
        
    
    &lt;/form&gt;


controller:
Code:
function page_update()
        {            
            $this->pages_model->doImageUpload();    
        }

model:
Code:
var $pageImagePath;
    var $pageImagePathUrl;
    
    function Pages_model()
    {
        parent::Model();
        
        $this->pageImagePath = realpath(APPPATH . '../images/pages');
    }

function doImageUpload()
    {
        $config = array(
            'upload_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->pageImagePath
        );
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();
    }

The form does more, but ive removed all the excess to get this working. I hope you guys can help.

Thanks in advanced guys and gals.

Cheers,
Darren
#2

[eluser]danmontgomery[/eluser]
And would you care to share with us what the issue is? Wink
#3

[eluser]gafroninja[/eluser]
haha yea, it doesn't upload the image lol.
#4

[eluser]NeoArc[/eluser]
Hmm, try this:

Code:
$this->pageImagePath = realpath(APPPATH . '../images/pages').'/';
#5

[eluser]gafroninja[/eluser]
nope mate. tried.

I'm using MAMP for your reference. I've made the images folder and its children chmod 777.

Cheers
Darren
#6

[eluser]danmontgomery[/eluser]
If it doesn't upload the image, then the error can be retrieved with $this->upload->display_errors();
#7

[eluser]gafroninja[/eluser]
Ok solved, but I'm a little embarrassed to say :S

'upload_types' => 'jpg|jpeg|gif|png'

should be:

'allowed_types' => 'jpg|jpeg|gif|png'

lol

Thanks all for helping me get there in the end!




Theme © iAndrew 2016 - Forum software by © MyBB