View Single Post
ישן 23-06-09, 16:23   # 1
possible
חבר בקהילה
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
הודעות: 121

possible לא מחובר  

עזרה| העלאת קבצים מרובים

אני מנסה לבנות מערכת העלאת קבצים בלי הגבלה של מספר קבצים אז החלטתי ליצור מערך של כל הקבצים שמעלים אבל זה יוצר לי שגיאה אני חושב שתבינו יותר עם קוד:

PHP קוד:
<?php
echo <<< html
<script type="text/javascript">
var count=0;
function addFile()
{
var newdiv = document.createElement('files'+count);
newdiv.innerHTML = '<input type="file" name="file[]"><br />';
document.getElementById('files').appendChild(newdiv);
count++;
}
</script>

<form action="" method="post" enctype="multipart/form-data">
<div id="files">
<input type="file" name="file[]" /><br />
</div>
<input type="submit" name="submit" value="העלה" />
<input type="button" value="קובץ נוסף" onclick="addFile()" />
</form>
html;
if (isset(
$_POST['submit'])) {
    if (empty(
$_POST['file'])) {
        echo 
"no files were selected";
    } else {
        foreach (
$_POST['file'] as $file) {
            
print_r($file);
        }
    }
}
?>
הבעיה היא שהמערך מגיע כל הזמן ריק ולכן הוא כל הזמן רושם no files were selected.
אשמח לשמוע פיתרונות ממכם.
  Reply With Quote