2

I've got a simple image upload form, which isn't detecting an image being posted. I'm sure there's something I'm missing but I just can't seem to find it. Code below:

Form file:

<?php echo form_open_multipart( 'account/uploadimage' ) ?>

    <?php echo form_label('Image', 'userfile'); ?>

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

    <div class="formSubmit clearfix">
        <?php echo form_submit('submit', 'Update'); ?>
    </div>

<?php echo form_close(); ?>

Controller "/account/uploadimage"

var_dump( $this->input->post('userfile') ); // bool(false)
echo "<hr>";
var_dump( $_FILES['userfile']['name'] ); // The info I'm after

I want to make use of the Codeigniter facilities, so need $this->input->post('userfile') to work.

Any ideas as to why it gives me false?

Thanks

Paul

2 Answers 2

6

this won't work:

var_dump( $this->input->post('userfile') ); 

because user uploaded files are stored inside the $_FILES variable and not $_POST

just use the codeigniter's upload library

http://codeigniter.com/user_guide/libraries/file_uploading.html

Sign up to request clarification or add additional context in comments.

2 Comments

Providing correct code is very much helpful for newcomers.
link is broken.
0

Use something like this---

    if( ! is_dir(UPLOAD_PATH.'folder') ){mkdir(UPLOAD_PATH.'folder',0777,TRUE); };      
    $path=UPLOAD_PATH.'folder/';        
    $imgtmpname=$_FILES['eposter']['tmp_name'];
    $fullpath= $path .$imgname;
    $filename = $imgname;

    move_uploaded_file($imgtmpname,$fullpath);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.