Welcome Guest, Not a member yet? Register   Sign In
Uploading a file
#1

[eluser]Unknown[/eluser]
Hi Everyone,

Could you please help me with this?

I'm using the file uploading class to upload a file:
http://ellislab.com/codeigniter/user-gui...ading.html

However, it tries to upload a file even if I don't actually choose anything. This is particularly annoying when I'm trying to update a form which has the option to update an image.

If I'm using the following input in my form,

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

How do I check if a file has actually been chosen or not? I've tried the following statement and it does not work.

$filename = $this->input->post('userfile');
#2

[eluser]eoinmcg[/eluser]
Hi,

Uploads are stored in $_FILES rather $_POST, hence not showing up in $this->input->post('fieldname')

Try
Code:
if($_FILES)
  {
    // manage uploaded file(s) here
  }
else
  {
    // no files uploaded
  }

There may be a better way of doing it, though this works for me...
#3

[eluser]spagi[/eluser]
Code:
if (isset($_FILES['userfile']))
{

some code
}
else {
some code
}




Theme © iAndrew 2016 - Forum software by © MyBB