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>
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>
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
