Jump to content

Archived

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

Chips

http file uploads...

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.

Share this post


Link to post
Share on other sites
I believe for the path under windows you have to include the full thing, including drive name... like mine was "E:/something/something/something/users/d/l/i/n/g/e/r/www/upload/"

Share this post


Link to post
Share on other sites

×

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.