I'm trying to detect if a file was selected using the CodeIgniter input class:
Using the Form Helper to output an upload input in my view:
echo form_upload('image', isset($ad)?$ad['image']:"", 'placeholder="Image" title="Please Choose A File"');
And in my controller:
private function handleUpdate()
{
$image = $this->input->post('image');
if($image != none && $image != "")
{
$this->handleImageUpload();
}
}
This of course is a stripped down function, but to illustrate the problem:开发者_运维问答 $image is always coming out empty. What's going on? Using CI 1.7.3
Try this:
if(isset($_FILES['image']['tmp_name'])) {
do_something();
}
You should use $_FILES
with uploading files.
$this->input->post('image') == $_POST['image'];
And make sure you use <form enctype="multipart/form-data">
Thorpe Obazee was right. This worked for me:
if ($this->input->post('img') == $_FILES['img'])
{
//do upload and resize
}
精彩评论