Results 1 to 2 of 2

Thread: File Upload

  1. #1
    Join Date
    Nov 2007
    Location
    Jakarta
    Posts
    3

    Unanswered: File Upload

    Create file upload.php

    <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td><strong>File Upload </strong></td>
    </tr>
    <tr>
    <td>Select file
    <input name="ufile" type="file" id="ufile" size="50" /></td>
    </tr>
    <tr>
    <td align="center"><input type="submit" name="Submit" value="Upload" /></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>

    ------------------------------------------------------------------------

    Create file upload_ac.php


    <?php

    $path= "upload/".$HTTP_POST_FILES['ufile']['name'];
    if($ufile !=none)
    {
    if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
    {
    echo "Successful<BR/>";


    echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>";
    echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
    echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
    echo "<img src=\"$path\" width=\"150\" height=\"150\">";
    }
    else
    {
    echo "Error";
    }
    }
    ?>
    ------------------------------------------------------------------------

    i've tried those code but didn't works. what should i do next? help.

    thanx in advance ^^

  2. #2
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    $HTTP_POST_FILES are depreciated and are turned off by default in current versions of php. Use $_FILES instead.

    It is also likely that an upload error is preventing the code from having anything to process.

    You should always check the ['error'] element to see if the upload was successful or if it failed and why.

    See the sample php code on how to use the $_FILES array at this link - http://www.php.net/manual/en/features.file-upload.php

    And the meaning of the values in the ['error'] element - http://www.php.net/manual/en/feature...oad.errors.php

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •