I think the error is on the if ! isset line.
When I upload a file and press submit it doesn't run the uploader.php script.
🙂
thanks,
if (!isset( $_FILES['uploadedfile']['tmp_name'])){
echo '
<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">
// <input type="hidden" name="MAX_FILE_SIZE" value="100000" >
<h2 align='center'> Cart Inventory Form</h2>
<table align='center'>
<tr>
<td>
<select name='unit'>
<option value=''>Select BU</option>
<option value='5'>5</option>
<option value='10'>10</option>
<option value='13'>13</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='20'>20</option>
<option value='21'>21</option>
</select>
</td>
<td>
Cart ID:<input type= 'text' size="10" maxlength=10 name='cart_id' /> </ br>
</td>
</tr>
<tr>
<td>
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
</td>
</tr>
<tr>
<td>
<input type='submit' name="submit" value='Upload File' />
</td>
</tr>
</table>
</form>
';
}else{
header("LOCATION:".$_POST['uploader.php']."?path=".urlencode($target_path));
}
the uploader.php
$target_path = "file_uploads/";
// Add the original filename to our target path.
//Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}