I have a problem, with upload images, but more inputs.
I want that When user is upload an image,then the image creating in ../upload with the renaming: ID variable $i Variable --> This an image id( $_FILES['tmp_name'][ $i ] Picture Description variable
And my problem that the images don't upload. But one image is upload, and the image name is 25-0-Description.jpg, and 25-2-Description.jpg nowhere
Advert class / Image Upload function
public function ImageUpload($file)
{
global $id,$termek_neve;
for($i = 0;$i < count($file['name']);$i++)
{
if(!empty($file['tmp_name'][$i]))
{
$name = $this->t_id.'-'.$i.'-'.$this->t_nev.".jpg";
$name = removeAccents($name);
$success = move_uploaded_file($file['tmp_name'][$i],
UPLOAD_DIR . $name);
if (!$success) {
return false;
} else return 1;
chmod(UPLOAD_DIR . $name, 0644);
}
}
}
In Image Upload php file
...
$ad = new Advert();
...
$file = $_FILES['ex1'];
$img = $ad->ImageUpload($file);
...
//inputs
<form accept-charset="UTF-8" method='POST' enctype="multipart/form-data">
<input type='file' id='' name='ex1[]' />
<input type='file' id='' name='ex1[]' />
<input type='file' id='' name='ex1[]' />
<input type='file' id='' name='ex1[]' />
<input type='file' id='' name='ex1[]' />
... // ^-- more inputs
</form>
Result: First image is uploading, ID-0-description.jpg,
Aucun commentaire:
Enregistrer un commentaire