UPLOAD POZA cu status in procente
Scris: Vin Noi 07, 2014
Am nevoie de un cod de incarcare imagine pe site dar sa apara cat la % sa incarcat in fiecare moment.
Cursuri online, tutoriale, jocuri si anime - gratuite
https://marplo.net/forum/
Cod: Selectaţi tot
<input type="file" name="uploadedfile" id="uploadedfile"><br>
<div class="progress">
<div class="bar"></div >
<div class="percent"></div >
</div>
<div id="status"></div>
<span class="statusaddpoza" style="color:red;"></span>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
document.getElementById('uploadedfile').addEventListener('change', function(e){
var getval = e.target.value;
var poza = $('#uploadedfile').val();
var pacc = (".jpg", ".jpeg");
if(poza.search(pacc) == -1)
{
$('.statusaddpoza').html('<img class="error" src="/inregistrare/stare-error.png"> Te rugam alege din calculator o poza de tip .jpg!');
}
else
{
$('.statusaddpoza').html('<img class="error" src="/inregistrare/stare-succes.png">');
(function() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
bar.width("100%");
percent.html("100%");
status.html(xhr.responseText);
}
});
})();
}
});
</script>
Cod: Selectaţi tot
<input type="file" name="uploadedfile" id="uploadedfile" />
Cod: Selectaţi tot
<form action="fisier_upload.php" id="form_up" method="post" enctype="multipart/form-data">
<input type="file" name="uploadedfile" id="uploadedfile" />
</form>
<div class="progress">
<div class="bar"></div >
<div class="percent"></div >
</div>
<div id="status"></div>
<span class="statusaddpoza" style="color:red;"></span>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
// to auto submit the form with ajax from jquery.form.js plugin
function ajaxFrm() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form').ajaxSubmit({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
bar.width("100%");
percent.html("100%");
status.html(xhr.responseText);
}
});
return false;
}
document.getElementById('uploadedfile').addEventListener('change', function(e){
var getval = e.target.value;
var poza = $('#uploadedfile').val();
// check file extension, add extensions separated by | (ext1|ext2|ext3)
if(poza.match(/\.(jpg|jpe|jpeg)$/i) == null) {
$('.statusaddpoza').html('<img class="error" src="/inregistrare/stare-error.png"> Te rugam alege din calculator o poza de tip .jpg!');
}
else {
$('.statusaddpoza').html('<img class="error" src="/inregistrare/stare-succes.png">');
ajaxFrm();
}
});
</script>
Cod: Selectaţi tot
<?php session_start(); include('../conectare.php'); include('../meniu-sus.php');
// daca e logat si acceseaza adresa de inregistrare il redirectioneaza catre propriul profil
if(isset($_SESSION['nume'])) {
header("Location: /profil-$_SESSION[nume].php");
}
else {
// daca nu afiseaza pagina de inregistrare
}