Jump to content

http file uploads...


Chips

Recommended Posts

The code is near identical to that of php.net's example... and it WORKS under linux/apache servers. However, I am trying to get the darned thing working upon WINDOWS IIS instead, which is giving problems. So it works on one platform, but not on another. Essentially the question is, does anyone know why? Sessions can be written to the local temp folder of the windows server, so I would have assumed that it's okay to upload files to that location as well (only admins can upload files, and at this moment-  security isn't an issue, tis a local server for local people... no strangers on here!).

[code]
<table width="100%" class="padded">
      <tr height="140">
        <td align="center">
          <form enctype="multipart/form-data" action="uploader.php" method="POST">
          <input type="hidden" name="MAX_FILE_SIZE" value="11111111" />
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td>
                Choose a file to upload:
              </td>
              <td rowspan="2">
              <input name="userfile" type="file" />
              </td>
            </tr>
            <tr>
              <td><span class="small">(max filesize is 1111111)</span>
              </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="submit" name="submit"/>
                </td>
            </tr>
          </table>
          </form>
        </td>
      </tr>
    </table>

[/code]


Uploader.php
[code]
// Where the file is going to be placed
$target_path = '';

/* Add the original filename to our target path. 
Result is "uploads/filename.extension" */
$target_path = $target_path . basename($_FILES['userfile']['name']);
echo $target_path;
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['userfile']['name']).
    " has been uploaded";
} else{
    echo $_FILES['userfile']['error'] ." - error uploading the file, please try again!";
    print_r($_FILES);
}
?>[/code]

Any input or suggestions would be much appreciated.
Link to comment
https://forums.phpfreaks.com/topic/13733-http-file-uploads/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.