Answer the question
In order to leave comments, you need to log in
How to change file name to user id?
Good evening. Such a problem, you need to change the file name to the name of the user id. Uploading via ajax upload. How to solve the problem?
How to pass namefile variable?
var button = $('span.upload-file'), interval;
var namefile = $('.main-user-id').val();
$.ajax_upload(button, {
action : '/upload.php',
name : 'round',
onSubmit: function(file, ext) {
this.disable();
$('span.upload-file').html('загружаем <i class="fa fa-spinner"></i>');
},
onComplete: function(file, response) {
this.enable();
alert(namefile);
$('span.upload-file').html('залить на сервер <i class="fa fa-upload">');
}
});
Answer the question
In order to leave comments, you need to log in
Form the file manually.. i.e. name ... you will find out the extension .. and the name manually .. sometimes I format it like this
$filename = pathinfo($_FILES['file']['name'], PATHINFO_FILENAME);
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$uid = uniqid();
$fn = Utils::translitUrl($filename).'-'.$uid.'.'.$ext;
$destination = IMAGE_COLLECTION. '/' . $fn;
move_uploaded_file( $_FILES['file']['tmp_name'] , $destination );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question