Upload several images and insert names on db (Script problem)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
  //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



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux