I have a page where a user can upload images to my website.
What I want is for users who aren't signed up to the site to only be able to upload once, this goes together with other information they enter into a form. The can ofcourse upload, then refresh the page but it will be an entirely new entry in the database i.e. they can't have more than one image per database entry.
Users that are registered and signed in, can upload multiple images per form. This is not a problem.
My issue is, is that I would like a solid solution to prevent non-registered users from uploading more than once.
I could remove or disable the upload input once upload is complete, but this seems clumsy and anyone with half a brain could easily get around it by putting the input field back in with a browser code inspector.
Here is my javascript for the Kendoui uploader:
$('#files').kendoUpload({
multiple: function()
{
var r;
call({call: 'user->isloggedin'}, function(data) {
if (data == 1)
{
r = true
} else {
r = false
}
}, false);
return r;
},
async: {
saveUrl: ROOT + 'share/upload',
removeUrl: ROOT + 'share/remove',
autoUpload: true
},
localization: {
select: 'Select car(s) to upload...',
remove: 'Delete'
},
error: function(e) {
var msg = '<b>' + e.files[0].extension + '</b> files can not be uploaded.';
modalError(msg, 'Upload error');
},
upload: function(e) // When each image finishes uploading...
{
},
progress: function(e)
{
},
success: function(e)
{
var name = "_" + e.files[0].name.replace(".", "_");
if (e.operation == 'upload')
{
$('#previews').append('<img style="display:none;" id="' + name + '" src="' + ROOT + 'cars/thumbs/' + e.files[0].name.toLowerCase() + '"/>');
$('#' + name).fadeIn('slow');
}
else if (e.operation == 'remove')
{
$('#' + name).fadeOut('slow', function() {
$('#' + name).remove();
})
}
}
})