הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   PHP | מערך קבצים (https://hosts.co.il/forums/showthread.php?t=62048)

mayden 18-04-08 13:09

בעיקרון תעשה משהו כזה:
PHP קוד:

 for($i 0$i sizeof($_FILES['uploadedfile']['name']); $i++) {
$type $_FILES['uploadedfile']['type'][$i];
$file $_FILES['uploadedfile']['name'][$i];
..
..


לולאה על סה"כ פעמים הקבצים שהועלו.

Labs 18-04-08 21:28

אולי עשיתי משהו לא טוב בטופס
HTML קוד:

<form method="post" id="regf" action="myprofile.php?act=Gupload1">
<table width="100%"><tr><td colspan="2" class="regit">העלאת תמונות לגלריה</td></tr></table>
<table width="100%">
<tr><td style="width: 150px;" align="center">כתובת התמונה</td><td style="width: 150px;" align="center">כותרת התמונה</td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
<tr><td style="width: 150px;" align="center"><input type="file" name="pic[]" style="width: 150px;" /></td><td style="width: 150px;" align="center"><input type="text" name="t[]" style="width: 150px;" /></td></tr>
</table>
<table>
<tr><td width="100%" align="center"><input type="submit" name="submit" style="margin: 10px;" value="שלח" /></td></tr>
</table>
<table height="6"><tr height="6"><td height="6"></td></tr></table>
</form>


PHP קוד:

case "Gupload1":
$pic[]=$_POST['pic'];
$t[]=$_POST['t'];
$folder="gallery/".$usernamef;
    if (!(
is_dir($folder))){
    
mkdir("$folder");
}
// foreach ($pic as $k => $v) {
 
for($i 0$i sizeof($HTTP_POST_FILES['pic']['name']); $i++) {
$v=$pic[$i];
    if (
$v!="") {
if (!(
is_numeric($te))) {
$testt=$t['$k'];
$temysql_real_escape_string($testt);
}
//num id
$numid mysql_query("select * from `gpic`"); 
$numid mysql_num_rows($numid);
if (
$numid=="") {
$id=1;
} else {
$y=0;
for (
$ii=1;$ii<=$numid;$ii++) {
$nuum mysql_query("select * from `gpic` WHERE `id`= '$ii'"); 
$nuum mysql_num_rows($nuum);
if (
$nuum=="") {
$id=$ii;
$ii=999999999999;
$y=1;
}
}
if (
$y==0) {
$id=$numid+1;
}
}
// end num id

$file_name $HTTP_POST_FILES['pic']['name'][$i];
echo 
"$file_name";
echo 
"<br />";
$msiu=getlast($file_name);
$new_file_name=$id.$dottt.$msiu;
    
$path"gallery/".$usernamef."/".$new_file_name;
echo 
"$path";
echo 
"<br />";
for(
$i=0;$i<count($file_ext_allow);$i++)
        {
            if (
getlast($file_name)!=$file_ext_allow[$i])
                
$test.="~~";
        }
$exp=explode("~~",$test);
        if (
count($exp)!=(count($file_ext_allow)+1))
        {
if(
copy($HTTP_POST_FILES['pic']['tmp_name'], $path))
{
$rashi=1;
// סוף העלאת תמונות

$add "INSERT INTO gpic (id, user, last, ko) VALUES ('$id', '$usernamef', '$msiu', '$te')";
mysql_query($add);
} else {
echo 
"העלאת התמונה נכשלה <br />";
}
} else {
echo 
"סוג קובץ אסור <br />";
}

}


כל הקוד המלא
אני לא מצליח לתקן את זה בשום דרך יושב על זה כבר יום שני


כל הזמנים הם GMT +2. הזמן כעת הוא 23:21.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ