1

I now have a file uploader that goes on like this

This is the index.php:

<form action="sendfotos.php" method="post" enctype="multipart/form-data">
Imagem: <input name="imagen" type="file" size="35"> <br />  
<input name="submit" type="submit" value="Upload"> 
</form>

This is the sendfotos.php:

<?php
$conexion=mysql_connect("host","user","password")or die("Problemas en la conexion");
mysql_select_db("bdname",$conexion) or
  die("Problemas en la seleccion de la base de datos");
$nomimagen= $_FILES['imagen']['name'];
if(move_uploaded_file ( $_FILES [ 'imagen' ][ 'tmp_name' ], '../gallery/user/'.$_FILES [ 'imagen' ][ 'name' ])) {
    echo "<link rel='stylesheet' href='adminstyle.css' type='text/css' media='all'><div id='page'><div id='agendasend'><br><br>Midia añadido con exito<br><br><br><a href='fotos.php'>Volver</a></div></div>";
mysql_query("insert into galeriafotos (imagen,id) values 
                        ('$nomimagen','$_REQUEST[id]')");
} else{
    echo "There was an error uploading the file, please try again!";
}  
?>

But now I need to use a multiuploader, which is the best solution? Upload multiple files at once and still save each one of them in the MySQL database.

Thanks in advance

steps
  • 774
  • 2
  • 16
  • 38

2 Answers2

1

Create function that moves uploaded file into your photo folder and inserts it into database then iterate over multiple files received by POST and call that function on each one. This is for not repeating code.

Alex Amiryan
  • 1,374
  • 1
  • 18
  • 30
  • But who do I recieve multiple files at once? I don't want the user to select multiple photos by clickin into many forms, I want multiselector – steps Apr 02 '12 at 13:15
  • 1
    I was talking about PHP backend. If you want to place multi selector for files on frontend try [YUI Uploader](http://developer.yahoo.com/yui/uploader/) – Alex Amiryan Apr 02 '12 at 13:19
0

I need to solve similar problem, did a big research and then I chose the plupload library for this. You also need a code at serverside, which gets more sophisticated if you need chunked upload (needed for uploading big files, where the size goes beyond PHP limits of the hosting), but don't worry - examples for serverside handling are also bundled with the library.

Community
  • 1
  • 1
Tomas
  • 57,621
  • 49
  • 238
  • 373