Uploading Script!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • boarderstu@gmail.com

    Uploading Script!

    i have a script that runs ok on the lycos webserver, but due to it
    being unreliable, i've moved to another free server for testing. the
    script is as follows:

    PHP Code:
    <?php

    $store_dir = BASE_DIR."galle ry/images/";

    #check if the string of the file name given is more than one.
    if( strlen($_POST['upfile']['name']) < 1 )
    {
    echo("Error! No files to upload... Exiting");
    exit();
    }
    #check the directory exists
    if( !is_dir($store_ dir) )
    {
    echo("Specified directory is not valid... Exiting");
    @unlink($_POST['upfile']['tmp_name']);
    exit();
    }
    #copying the file
    if( @copy($_POST['upfile']['tmp_name'] ,
    $store_dir.$_PO ST['upfile']['name'] ) )
    {
    echo("Uploaded ".$_POST['upfile']['name']." successfully.") ;
    }
    else
    {
    echo("Upload of ".$_POST['upfile']['name']." to ".$store_di r."
    failed!!!!<BR>" );
    }
    @unlink($_POST['upfile']['tmp_name']);
    echo BASE_DIR;
    ?>


    and form:

    PHP Code:
    <head><body>
    <form enctype="multip art/form-data" action="do_uplo ad.php"
    method="POST">
    <input type="hidden" name="MAX_FILE_ SIZE" value="8192">
    <input name="upfile" type="file">
    <input name="store_dir " type="hidden" value="/images/">
    <input type="submit" value="Send File">
    <input type="reset" value="reset">
    </form>
    </body></head>


    but the problem is, the postdata is not being read by the script as it
    exits at the first IF statement saying there is no file.

    anyhelp?

    thanks!

Working...