The default name for this file is upload.php

This script will upload the files into the current directory or where ever upload.php is located. You can change this in the function move_uploaded_file().

<?php
foreach($_FILES['userfile']['name'] as $key => $value){
  $upload_dir = '/upload/me/to/here/';
  $filename = $_FILES['userfile']['name'][$key];
  $tmpfile = $_FILES['userfile']['tmp_name'][$key];
  move_uploaded_file($tmpfile,$upload_dir . $filename);
}
?>
<html>
<head>
<title>Upload</title>
<script type="text/javascript">
function add(){
  var preinputtext = document.createElement('span');
  preinputtext.innerHTML = 'Attach File: ';
  var attachment = document.createElement('input');
  attachment.setAttribute('name', 'userfile[]');
  attachment.setAttribute('type', 'file');
  var linebreak = document.createElement('br');
  document.getElementById('content').appendChild(preinputtext);
  document.getElementById('content').appendChild(attachment);
  document.getElementById('content').appendChild(linebreak);
}
</script>
</head>
<body>
<form action="upload.php?formsent=yes" method="post" enctype="multipart/form-data">
<p>
Attach File: <input type="file" name="userfile[]" /><br />
<span id="content">

</span>
<a href="#addfile" onClick="add()">Attach another file</a><br />
<input type="submit" value="upload" />
</p>
</form>
</body>
</html>

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.