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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.