0
I have the following code that uploads photos:
<script type="text/javascript" src="js/jquery-1.6.1.min.js" ></script>
<script type="text/javascript" src="js/ajaxupload.3.5.js" ></script>
<link rel="stylesheet" type="text/css" href="./styles.css" />
<script type="text/javascript" >
$(function(){
var btnUpload=$('#upload');
var status=$('#status');
new AjaxUpload(btnUpload, {
// Arquivo que fará o upload
action: 'upload-file.php?cliente=<?php echo $cliente; ?>&cod=<?php echo $cod; ?>',
//Nome da caixa de entrada do arquivo
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
// verificar a extensão de arquivo válido
status.text('Somente JPG, PNG ou GIF são permitidas');
return false;
}
status.text('Aguarde! Foto do imóvel sendo enviada...');
status.css("color", "#B90407");
status.css("font-size", "20px");
status.css("text-indent", "25px");
},
onComplete: function(file, response){
//Limpamos o status
status.text('');
//Adicionar arquivo carregado na lista
if(response==="success"){
$('<li></li>').appendTo('#files').html('<strong>Foto inserida com sucesso!').addClass('success');
} else{
$('<li></li>').appendTo('#files').html('<strong>Foto inserida com sucesso!').addClass('success');
}
}
});
});
</script>
And this is where the button appears to select the image files to upload:
<div id="mainbody" >
<div id="upload" ><span>Inserir fotos<span></div><span id="status" ></span>
<ul id="files" ></ul>
</div>
I need to enter this code jsfiddle , but when I implement this code the button to select the files stops working.
It would be the last thing of great importance I need to finish my site. Can anyone solve this problem for me?
Why don’t you use the
<input type="file">
?– Guilherme Lopes
@Guilhermelopes But how would this implementation?
– Gladison Neuza Perosini
@Guilhermelopes would you do this programming service for me? We could combine?
– Gladison Neuza Perosini
I believe that this is unethical, because I think that the SOPT is not addressed to this, but coming back to your question, beyond your problem, I point out that you do the file check by the back end as well. The original file upload button is
<input type='file'>
. And I believe it won’t work if you wear something different.– Guilherme Lopes