1
0
Fork 0

Start to accept files via standard upload in case of browser or user incompetence.

This commit is contained in:
Andrew Tomaka 2011-11-20 23:53:17 -05:00
parent 4322822906
commit f5160b9916
3 changed files with 39 additions and 1 deletions

View File

@ -6,7 +6,7 @@ class Upload extends CI_Controller {
}
public function process() {
header('Content-Type: application/json',true);
header('Content-Type: text/html',true); //application/json
$temp_name = md5(rand());

View File

@ -55,5 +55,41 @@
<script src="/js/jquery.altAlert.js"></script>
<script src="/js/jquery.filedrop.js"></script>
<script src="/js/upload.js"></script>
<script src="/js/jquery.upload-1.0.2.js"></script>
<script type="text/javascript">
$(function() {
$('#single_upload').change(function() {
$(this).upload('/upload/process/', function(response) {
if(response.type == 'error') {
alert('There was an error: ' + response.status);
return false;
} else {
// $.data(file).addClass('done');
// $.data(file).find('.linkBox').val(response.file);
// $.data(file).find('.linkBox').click(function() {
// this.focus();
// this.select();
// });
$('#dropbox').append($('<div>')
.append($('<input>')
.attr('type', 'text')
.val(response.file)
.addClass('linkBox')
)
);
$('#dropbox').find('.linkBox:last').click(function() {
this.focus();
this.select();
});
alert('success');
}
}, 'json');
});
});
</script>
</body>
</html>

View File

@ -1,3 +1,5 @@
<div id="dropbox">
<span class="message">Drop images here to upload.</span>
<br/><br/>
<center><input type="file" name="image" id="single_upload"></center>
</div>