CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    20

    Help for file uploading

    Hello to everybody!
    I've written a short PHP script for menaging the file uploading. the problem is that it doesn't upload every kind of file but only some (for ex. .txt and .doc). If someone can tell me why. i'd be grateful. Thanks and byez
    Follows the code:


    $uploaddir="C:/apache2triad/htdocs/tu4tu/Uploads/"; //Set the upload directory in the server machine

    if((isset($_POST['action'])) && ($_POST['action'] == 'Alttach')) {

    $uploadfile=$uploaddir.$_FILES['userfile']['name'];

    echo $_FILES['userfile']['tmp_name'];

    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

    echo "<br>".basename($uploadfile);
    ?>
    <table>
    <tr>
    <td>File uploaded!</td>
    </tr>
    </table>
    <?php } else {
    ?>
    <table>
    <tr>
    <td>File not uploaded!</td>
    </tr>
    </table>
    <?php
    }
    }
    ?>

    <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="10000000">
    <input type="file" name="userfile">
    <input type="submit" name="action" value="Attach">
    </form>

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Help for file uploading

    If it is only uploading certain file types, the problem is most likely the server restrictions. Check your server settings to see what MIME types it handles.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Mar 2005
    Posts
    20

    Re: Help for file uploading

    Problem solved!!
    As you said it was a configuration problem.
    I left the POST_UPLOAD_SIZE set at 2 MB (retard)!
    Thank you wery much!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured