Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <form action="processStuff.php" enctype="multipart/form-data" method="POST">
- username: <input type="text" name="username" />
- password: <input type="password" name="password" />
- <p>
- <input type="file" name="uploadFile[]" /><br />
- <input type="file" name="uploadFile[]" /><br />
- <input type="file" name="uploadFile[]" /><br />
- <!-- Add as many of these as you want -->
- </p>
- <p>
- <input type="submit" />
- </p>
- </form>
- </body>
- </html>
- <pre>
- <?php
- echo '<h2>Username & password</h2>'
- echo "Username: {$_POST['username']}nPassword: {$_POST['password']}";
- echo '<hr />';
- echo '<h2>Uploaded files</h2>'
- foreach($_FILES['uploadFile']['tmp_name'] as $i => $tempUploadPath) {
- if (empty($tempUploadPath)) {
- // this <input type="file" /> was "blank"... no file selected
- } else {
- // a file was uploaded
- echo '<strong>A file named "', $_FILES['uploadFile']['name'][$i], "" was uploaded</strong>n";
- echo "ttemporarily stored at: ", $tempUploadPath, "n";
- echo "tmime type: ", $_FILES['uploadFile']['type'][$i], "n";
- echo "tsize: ", $_FILES['uploadFile']['size'][$i], " bytesn";
- echo "terror code",
- ((empty($_FILES['uploadFile']['size'][$i])
- ? '<em>no errror</em>'
- : $_FILES['uploadFile']['size'][$i])),
- "nn";
- // do something useful with the uploaded file
- // access it via $tempUploadPath and use move_uploaded_file() to move
- // it out of the temp path before you manipulate it in any way!!!!!
- // see http://us3.php.net/features.file-upload
- // and http://us3.php.net/manual/en/function.move-uploaded-file.php
- }
- }
- ?>
- </pre>
Add Comment
Please, Sign In to add comment