how to upload image?
<p>I want upload images in php here is my code</p>

<pre><code>if (isset($_FILES['userfile']['name'])) {
  if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
    $from = $_FILES['userfile']['tmp_name'];
    $to = "/var/www/html/images/".$_FILES['userfile']['name'];
    $res = move_uploaded_file($from, $to);
    if($res)
    {
      print 'upload success';
    }  
    else
    {
      print 'fail';
    }               
</code></pre>

<p>here i got output fail please tell me correct process </p>

<p>thanks in advance</p>
