Scusate la domanda banale... (in asp me la cavo meglio)
ho un form che fa l'upload di un file e lo scrive nel database...
se volessi aggiungere anche un campo Titolo come posso aggiungerlo all'insert??
Codice PHP:
$max_size = 1024*250; // the max. size for uploading
$my_upload = new file_upload;
[B]$titolo=$_POST["titolo"]; [/B]
// "files" is the folder for the uploaded files (you have to create this folder)
$my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/files/new/";
$my_upload->extensions = array(".png", ".zip", ".pdf", ".jpg"); // specify the allowed extensions here
// $my_upload->extensions = "it"; // use this to switch the messages into an other language (translate first!!!)
$my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
$my_upload->rename_file = false; //decido se rinominare il file
// You need to modify the settings below...
$conn = mysql_connect("localhost", "root", "123456") or die(mysql_error());
mysql_select_db("casale", $conn) or die(mysql_error());
if(isset($_POST['Submit'])) {
$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
$my_upload->the_file = $_FILES['upload']['name'];
$my_upload->http_error = $_FILES['upload']['error'];
$my_upload->replace = "y";
$my_upload->do_filename_check = "n"; // use this boolean to check for a valid filename
if ($my_upload->upload()) { // new name is an additional filename information, use this to rename the uploaded file
mysql_query(sprintf("INSERT INTO eventi SET menu = '%s'", $my_upload->file_copy));
}
}
?>
praticamente i campi del db sono:
Menu "dove va il file caricato"
e
titolo "dove va $titolo "
come modifico la stringa insert INTO eventi
Grazie per la pazienza