Hi and thank you for stop here.
I made this script that upload 1 file and create a folder for this using as name a column from MYSQL. My problem is I have a very small knowledge of PHP and I will love to upload more pictures at the same time. I’m sure this is very easy if you know how to use variables.
Any help will very appreciate.
Here is the page where I browse the files:
[COLOR=Red]Index.php
[B]At the moment I can upload the picture only with button:<input name=”archivo” type=”file” id=”archivos” />
[code=php] <td>Pictures 6 </td>
<td>
<input name=”MAX_FILE_SIZE” type=”hidden” value=”100000″>
<input name=”Pictures6″ type=”file” id=”Pictures6″ /> </td>
</tr>
<tr>
<td>Pictures 7 </td>
<td>
<input name=”MAX_FILE_SIZE” type=”hidden” value=”100000″>
<input name=”archivo” type=”file” id=”archivos” />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type=”submit” name=”Submit” value=”Submit” /></td>
</tr>
<tr><td>
</form>
</td></tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Here is the uploading process + the creation of the folder
[COLOR=Red]insert_procesador.php
[code=php]<?php require_once(‘../../Connections/conn_newland.php’); ?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<META HTTP-EQUIV=”Pragma” CONTENT=”no-cache”>
<META HTTP-EQUIV=”Expires” CONTENT=”-1″>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<style type=”text/css”>
<!–
.style3 {font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif;}
–>
</style>
</head>
<body>
<span class=”style3″>
<li>
<?php
//
//Conecion a la DB
//
mysql_select_db($database_conn_newland, $conn_newland);
$query_Llamar_ID = “SELECT ID FROM tbl_news ORDER BY ID DESC”;
$Llamar_ID = mysql_query($query_Llamar_ID, $conn_newland) or die(mysql_error());
$row_Llamar_ID = mysql_fetch_assoc($Llamar_ID);
$totalRows_Llamar_ID = mysql_num_rows($Llamar_ID);
//
//Crea el folder
//
$addition = $row_Llamar_ID[‘ID’] + 1;
$itemCount = $addition ;
// “./” agrega ./ a la ruta del archivo JPEG
//$newDir = “./” . $itemCount;
$newDir = $itemCount;
mkdir($newDir);
$Pictures6 = archivo
//
//Hace el upload
//
$extension = explode(“.”,$_FILES[‘archivo’][‘tmp_name’]);
echo $extension;
$num = count($extension)-1;
if(($_FILES[‘archivo’][‘type’] == “image/pjpeg”) or ($_FILES[‘archivo’][‘type’]== “image/gif”)) {
/*
“$newDir/” Manda la foto a el nuevo folder creado.
“files/” Manda la foto a un folder llamado files.
*/
if(!move_uploaded_file($_FILES[‘archivo’][‘tmp_name’], “$newDir/”.$_FILES[‘archivo’][‘name’])) {
//if(!move_uploaded_file($_FILES[‘archivo’][‘tmp_name’], “files/”.$_FILES[‘archivo’][‘name’])) {
echo “error al copiar el archivo”;
}
else {
echo ” El archivo: “. $_FILES[‘archivo’][‘name’] .” se ha subido con exito”;
}
}
else {
echo “el formato de archivo no es valido, solo se admiten imagenes gif o jpg”;
}
?>
<br><br>
<li>
<?php
//echo “Este es el folder de destino para la imagen: ” .”$newDir/”.”$archivo”. $_FILES[‘archivo’][‘name’];
echo “Este es el folder de destino para la imagen: ” .”$newDir/”.$_FILES[‘archivo’][‘name’];
$resultado = “$newDir/”.$_FILES[‘archivo’][‘name’];
?>
<br>
<br>
<?php
$host = “localhost”;
$user = “root”;
$pwd = “root”;
$dbConn = mysql_connect($host,$user,$pwd);
$database = “newland_tours”;
mysql_select_db($database, $dbConn);
$query_rs_insert_news = “INSERT INTO tbl_news (Title, Country, City, Date,
1d, 2e, 3es, 4f, 5i, 6p, 7o, deutch, english, espanol, francaise, italiano,
portugues, otro, Picture1, Picture2, Picture3, Picture4, Picture5, Picture6,
Picture7) VALUES (‘”.$_POST[‘Title’].”‘, ‘”.$_POST[‘Country’].”‘,
‘”.$_POST[‘City’].”‘, ‘”.$_POST[‘Date’].”‘, ‘”.$_POST[‘1d’].”‘,
‘”.$_POST[‘2e’].”‘, ‘”.$_POST[‘3es’].”‘, ‘”.$_POST[‘4f’].”‘, ‘”.$_POST[‘5i’].”‘,
‘”.$_POST[‘6p’].”‘, ‘”.$_POST[‘7o’].”‘, ‘”.$_POST[‘1deutsch’].”‘,
‘”.$_POST[‘2english’].”‘, ‘”.$_POST[‘3espanol’].”‘,
‘”.$_POST[‘4francaise’].”‘, ‘”.$_POST[‘5italiano’].”‘,
‘”.$_POST[‘6portugues’].”‘, ‘”.$_POST[‘7otro’].”‘,
‘”.$_POST[‘Pictures1’].”‘, ‘”.$_POST[‘Pictures2’].”‘,
‘”.$_POST[‘Pictures3’].”‘, ‘”.$_POST[‘Pictures4’].”‘,
‘”.$_POST[‘Pictures5’].”‘, ‘”.$_POST[‘Pictures6’].”‘,
‘”.$resultado.”‘)”;
$rs_insert_news = @mysql_query($query_rs_insert_news);
if($rs_insert_news){
echo “hola”.$_FILES[‘uno’][‘name’];
}else{
echo mysql_error();
};
mysql_free_result($Llamar_ID);
?>
</span>
</body>
</html>
[COLOR=Red][SIZE=5]all the files here
[upl-file uuid=46fddc20-8bd8-4f14-bb8f-725e08d88742 size=3kB]files.zip