/    Sign up×
Community /Pin to ProfileBookmark

simple upload file does not work for me. HELP

I have run a simple file upload and it doesn’t work for me. Can someone tell me what the problem is? I have two simple files (one file will do the work too),


********
  • * file.php
    ********
    <html>
    <body>
  • <form enctype=”multipart/form-data” action=”uploader.php” method=”POST”>
    <input type=”hidden” name=”MAX_FILE_SIZE” value=”100000″ />
    Choose a file to upload: <input name=”uploadedfile” type=”file” /><br />
    <input type=”submit” name=”submit” value=”Upload File” />
    </form>

    </body>
    </html>


    **************
  • * uploader.php
    **************
    <?PHP
    if(isset($_POST[‘submit’]))
    {
    echo “tmp name is ” . $_
    FILES[‘uploadedfile’][‘tmp_name’] . “<br>”;
    echo “name is ” . $_FILES[‘uploadedfile’][‘name’] . “<br>”;
    echo “size is ” . $_
    FILES[‘uploadedfile’][‘size’] . “<br>”;
    echo “type is ” . $_FILES[‘uploadedfile’][‘type’] . “<br>”;
    }
    ?>
  • The output of uploader.php displays

    tmp name is
    name is DSC00678.JPG
    size is 0
    type is

    if I tried to upload a jpg file, and sometime displays correct info for pdf and doc file, but some time does not.

    tmp_name, size and type used to work for me all the time, suddenly it’s not working. I only have one linux machine which runs PHP. I’m running php 5.2.4 on linux/apache.

    Thanks.

    to post a comment
    PHP

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @MrCoderOct 17.2007 — Heya, echo out the error number.

    [code=php]
    echo $_FILES['uploadedfile']['error'];
    [/code]


    Or..
    [code=php]
    echo "<pre>".var_export($_FILES, true)."</pre>";
    [/code]


    Then compare the error number to this list.
    Copy linkTweet thisAlerts:
    @jfernandezauthorOct 17.2007 — Thanks MrCoder for the reply. I'll try that later at home.
    Copy linkTweet thisAlerts:
    @jfernandezauthorOct 18.2007 — Found the problem, I changed the MAX_FILE_SIZE to 4000000 makes it work. I verified with echo $_FILES['uploadedfile']['error'] and it returns 2. Thanks MrCoder.
    Copy linkTweet thisAlerts:
    @MrCoderOct 18.2007 — Glad I could help!
    ×

    Success!

    Help @jfernandez spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.6,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...