Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][JavaScript] Upload kilkudziesięciu fotek..., ...za pomocą jednego skryptu ?!
oomaster
post 1.08.2008, 14:10:34
Post #1





Grupa: Zarejestrowani
Postów: 305
Pomógł: 3
Dołączył: 4.08.2006
Skąd: GDA

Ostrzeżenie: (0%)
-----


Witam,

Przedstawię kod jaki posiadam a potem opiszę problem.
Kod
<script language="JavaScript">
function deleteFileInput(hyperlink)
{
    $(hyperlink).parent().remove();
    
    return false;
}

function createFileInput(description, max)
{
    var description = description ? true : false;
    var max = max ? max : false;
    
    var nextId = 0;
    
    var wrappers = $('.photoWrapper');
    
    if (!max || wrappers.length < max) {
        wrappers.each(function (i) {
            var id = parseInt($(this).attr('id').replace('photoWrapper', ''));
            if (id >= nextId) {
                nextId = id + 1;
            }
        });
    
        var p = $('<div>');
        div.addClass('photoWrapper');
        div.attr('id', 'photoWrapper' + nextId);
        
        var input = $('<input type="file" />');
        input.addClass('file');
        input.attr('name', 'photo[' + nextId + ']');
        div.append(input);
        
        if (description) {
            div.html(p.html() + ' Opis ');
            
            var input = $('<input type="text" />');
            input.addClass('text');
            input.attr('name', 'photo_description[' + nextId + ']');
            
            div.append(input);
        }
        
        var a = $('<a>');
        a.addClass('foto');
        a.attr('href', '');
        a.html(' usuĹ?');
        a.click(function () { return deleteFileInput(this); });
        
        div.append(a);
        
        div.insertAfter($('.photoWrapper:last'));
    }
    
    return false;
}
</script>

  1. <form action="foto.php" method="post" enctype="multipart/form-data">
  2. <div>
  3.  
  4. <input class="file" type="file" name="photo[0]" />
  5. <a class="foto" href="" onclick="return createFileInput();">+ więcej</a>
  6. </div>
  7. </form>


Teraz w pliku foto.php jest rozbudowany skrypt do uploadu fotek ale mój problem jest następujący jaką funkcją w php wszystkie fotki dodane za pomocą formularza obrobię przez ten jeden skrypt. Myślałem nad jakąś pętlą ale to chyba odpada ?

Czy to tego typu zadania foreach będzie ok ? Proszę o pomoc smile.gif
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 24.07.2025 - 21:16