0

I've written PHP scripts to upload files in the past, but for some reason this one isn't working…

The HTML looks like:

<form action="scripts/submit.php" method="push" enctype="multipart/form-data" name="submitGraphics" id="submitGraphics">
      <p>
        <label for="filefield"><strong class="red">*</strong> File:</label>
        <input name="filefield" type="file" id="filefield" tabindex="30" />
      </p>
</form>

The script looks like:

<?php

    $fileName = $_FILES["filefield"]["name"];
    $fileTmpLoc = $_FILES["filefield"]["tmp_name"];
    $fileErrorMsg = $_FILES["filefield"]["error"];

    echo "$fileName";
    echo "$fileTmpLoc";
    echo "$fileErrorMsg";
    print_r($_FILES);
?>

There is normally more afterwards, but I am now just testing to make sure the file is uploading (since it has not been working). All I get from this is nothing for the first three echo statements, and then a line saying Array().

I have modified the php.ini file in the nesesarry spots:

file_uploads upload_max_filesize max_execution_time post_max_size

halfer
  • 19,824
  • 17
  • 99
  • 186
Michael
  • 169
  • 2
  • 2
  • 9
  • Make sure to add tag with this attribute: `enctype="multipart/form-data"` Without it the files will not uploaded. – user2511140 Nov 29 '13 at 22:52
  • @user2511140 He already has that tag... – John Kurlak Nov 29 '13 at 22:54
  • What is in `$_FILES`? Do a `print_r` or `var_dump` on it and put the output in your post. – Sverri M. Olsen Nov 29 '13 at 23:22
  • @SverriM.Olsen $_FILES is `Array()`, as posted above. – John Kurlak Nov 29 '13 at 23:24
  • Then woopti-doo. Nothing was submitted, which probably means that there is something wrong with your HTML... which would be `method="push"`. The [HTTP protocol does not have a `push` method](http://tools.ietf.org/html/rfc2616#page-36); you probably meant to write `post`, yeah? – Sverri M. Olsen Nov 29 '13 at 23:26
  • Also, if the `$_FILES` array is empty then your code should show some "Undefined index" notices. You should [turn on errors and such](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php#answer-845025). – Sverri M. Olsen Nov 29 '13 at 23:35
  • It was supposed to be `post`, you're right. Don't know where `push` came from. And yeah, some of you are answering without even reading the question - a little too anxious to be first up. – Michael Nov 29 '13 at 23:36
  • @Michael Or the answers for that matter :) – John Kurlak Nov 29 '13 at 23:38

1 Answers1

1

Change method="push" to method="post"

John Kurlak
  • 6,594
  • 7
  • 43
  • 59