Reputation: 1
I like this multi file upload:
http://www.sitepoint.com/html5-javascript-file-upload-progress-bar/
but the backend sample is in php, can someone help me convert it to asp.net mvc3, or a nice starting point, not sure where to begin:
<?php
$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);
if ($fn) {
// AJAX call
file_put_contents('uploads/' . $fn,file_get_contents('php://input'));
echo "$fn uploaded";
exit();
}
else {
// form submit
$files = $_FILES['fileselect'];
foreach ($files['error'] as $id => $err) {
if ($err == UPLOAD_ERR_OK) {
$fn = $files['name'][$id];
move_uploaded_file($files['tmp_name'][$id],'uploads/' . $fn);
echo "<p>File $fn uploaded.</p>";
}
}
}
Upvotes: 0
Views: 519
Reputation: 887509
Just create an action that takes an HttpPostedFileBase fileselect
as a parameter.
MVC will do the rest.
Upvotes: 1