Jump to content
php.lv forumi

Vairaku failu uploads


Dzint

Recommended Posts

Nezinu ka lai veidoju vairaku failu uploadu.

Izveidoju formu ar vairakiem input laukiem

 

for ($sk=1;$sk<=2;$sk++) {

echo "<tr><td><input type='file' name='files.{$sk}' value='Meklēt' size='80'></td></tr>";

 

 

Pec tame meginu uploadot:

 

for ($ska=1;$ska<=2;$ska++) {

$target_path = "img/";

$target_path = $target_path . basename( $_FILES['files.{$ska}']['name']);

if(move_uploaded_file($_FILES['files.{$ska}']['tmp_name'], $target_path)) {

echo "<br>Fails ". basename( $_FILES['files.{$ska}']['name']).

" ir pievienot un ielādēts";

}

else{

echo "<br>Mēģinot augšupielādēt failu radās kļūda, mēģiniet velreiz!";

}

}

 

Bet kautkas nestraada.Varbuut nav pareizi defineeti tie input lauka vardi(name).

Link to comment
Share on other sites

Nelabi dari.

<form method="post" action="" enctype="multipart/form-data">
		<table border="1" cellpadding="1" cellspacing="0" class="gallery">
		<tr>
			<td>Bilde:</td>
			<td><input type="file" name="bilde[]"/></td>
		</tr>
		<tr>
			<td>Bilde:</td>
			<td><input type="file" name="bilde[]"/></td>
		</tr>
		<tr>
			<td>Bilde:</td>
			<td><input type="file" name="bilde[]"/></td>
		</tr>
		<tr>
			<td>Bilde:</td>
			<td><input type="file" name="bilde[]"/></td>
		</tr>
		<tr>
			<td colspan="2" align="center"><br/><input type="submit" name="add_gallery" value="Pievienot"/></td>
		</tr>
		</table>
		</form>

 

for ($x = 0; $x <= 3; $x++) {
		if ($_FILES['bilde']['error'][$x] != 4) {
			$dest = 'obj_gallery/small_'.$bilde;
			move_uploaded_file($_FILES['bilde']['tmp_name'][$x],$dest);
		}
	}

Edited by Toms
Link to comment
Share on other sites

×
×
  • Create New...