Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][JavaScript] Upload kilkudziesięciu fotek..., ...za pomocą jednego skryptu ?!
oomaster
post
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 (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
oomaster
post
Post #2





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

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


print_r($_FILES) wyświetla:

Cytat
Array
(
[photo] => Array
(
[name] => Array
(
[0] => DSC00135.JPG
)
[type] => Array
(
[0] => image/jpeg
)
[tmp_name] => Array
(
[0] => /tmp/phpSQvuje
)
[error] => Array
(
[0] => 0
)
[size] => Array
(
[0] => 381448
)
)
)


Powyżej pokazuje dla jednej fotki dla 2 foteki i więcej też działa ładnie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Sorry za post pod postem ale wynika z tego ,że najwyraźniej po błędzie coś nie tak jest z przesłaniem przez HTTP POST:

Cytat
if( is_uploaded_file( $val[0]['tmp_name'] ) )


Czyli plik nawet nie dostaje się do skryptu raczej
hhhmmmm...

Ten post edytował oomaster 3.08.2008, 08:37:30
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 Aktualny czas: 11.10.2025 - 19:56