PHP - upload.class image and $_FILES

Posted by Ockonal on Stack Overflow See other posts from Stack Overflow or by Ockonal
Published on 2010-04-10T11:36:41Z Indexed on 2010/04/10 11:43 UTC
Read the original article Hit count: 265

Filed under:
|
|

Hello, I'm using class.upload.php to upload pictures onto the server. Here is my form:

<form action="<?="http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>" method="post" enctype="multipart/form-data">
  <table style="width: 100%; padding-top: 20px;">
    <tr>
        <td>Image file:</td>
        <td><input type="file" name="image_file" /></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td align="right"><input type="submit" name="add_new" value="Add image" /><td></td>
    </tr>
</table>
</form>

In php code I do:

if( array_key_exists('add_new', $_POST) )
{
    echo 'add new is in array';

    echo '<pre>';
    print_r($_POST);
    print_r($_FILES);
    echo '</pre>';

    $handle = new Upload($_FILES['image_file']);
    ...
}

Here is an output of print_r:

Array
(
    [image_file] => somefile.png
    [add_new] => Add image
)
Array
(
)

As you can see second array is empty ($_FILES), so image doesn't upload. Why?


  • operating system : Linux
  • PHP version : 5.2.12
  • GD version : 2.0.34
  • supported image types : png jpg gif bmp
  • open_basedir : /home/httpd/vhosts/kz-gbi.ru/httpdocs:/tmp

© Stack Overflow or respective owner

Related posts about php

Related posts about upload