Propriete yılında varlık ben 5 alanı da denir image1 image2 image3 image4 image5PHP concatanate değişkeni adı
ben döngü
Bunu denedim bir de bu alanları eklemek için wan't ancak yok iş:
for($i=0;$i<count($this->request->data['files'])&&$i<5;$i++){
//... some code
$propriete->{'image'.$i+1} = $file['name'];
}
}
Birisi bana yardımcı olabilir mi?
DÜZENLEME
Bu benim döngünün kodudur:
for($i=0; $i<count($this->request->data['files']) && $i<5; $i++){
$file=$this->request->data['files'][$i];
$ext = substr(strtolower(strrchr($file['name'], '.')), 1); //get the extension
$arr_ext = array('jpg', 'jpeg', 'gif'); //set allowed extensions
if(in_array($ext, $arr_ext))
{
//do the actual uploading of the file. First arg is the tmp name, second arg is
//where we are putting it
move_uploaded_file($file['tmp_name'], WWW_ROOT . '/img/' . $file['name']);
debug($file['name']);
//prepare the filename for database entry
$propriete->{'image'.$i+1} = $file['name'];
}
}
'$ dosya ['name']' hiçbir anlam ifade etmiyor, lütfen bu değişkenin nereden geldiğini açıklamak için yeterli kodu göster – RiggsFolly
@RiggsFolly düzenlemeyi kontrol edin –
Hatanın hangi satırda göründüğünü belirtebilir misiniz? $ Propriete -> {'image'. $ I + 1} = $ file ['name']; Dosya ismini almadınız mı yoksa nesne adı – WebInsight