Re: Problem on loop upload images

From: Date: Tue, 13 May 2003 12:32:02 +0000
Subject: Re: Problem on loop upload images
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147418@lists.php.net to get a copy of this message
Dani Matielo wrote:
Hello, for ($i=1; $i<=$quantas; $i++) { if (trim($_FILES['imagem']['name'][$i])!="") { //this is the original name of the image(imagem[$i] was the field in the form) $file_name = $_FILES["$imagem"]["name"][$i]; //heres the place on the server $file_path = $_FILES["$imagem"]["tmp_name"][$i]; //heres the original extension $extensao = substr ($file_name,-3,3); $file_name or $file_path? Also you cannot know the extension will be last 3 chars, can be 2, 4, or even more. Use filepath() instead.
//heres some other information $id_materia=$_POST['id_materia']; //the name of the image is a composition $nome_imagem = "imagem_".$id_materia."_".$i.".".$extensao; //this is the place ill put it $new_path = "c:/apache/htdocs/cirandabrasil/img/materias/".$nome_imagem; //this is moving move_uploaded_file ($file_path, $new_path); //this is inserting on the db $imagens = $imagem[$i]; mysql_query("INSERT INTO materias_imagens (id_materia, nome) VALUES('$id_materia', '$nome_imagem')"); echo "Materia ".$i." ok.<br>"; }; the name things work well, and I get the information on the db, but not the extension... meaning that the files are not uploaded!! What am I doing wrong? Thank you, :) Dani --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.476 / Virus Database: 273 - Release Date: 24/4/2003


« previous php.general (#147418) next »