potete controllare se sono fatti bene questi file perchè se li provi non me li uppa nel database e ne nella cartella aiutatemi
connessione.php
Codice PHP:
<? $db_host = "localhost"; $db_user = "user"; $db_password = "pass"; $db_database = "my_uploadsuper"; $connessione=mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_database,$connessione); ?>
index.html
Codice PHP:
<html> <head> <title>upload</title> </head> <body> <form action="upload.php" method="post"> <input type="file" name="file" /> <input type="submit" value="Carica" name="submit" /> </form> </body> </html>
db.sql
Codice PHP:
CREATE TABLE IF NOT EXISTS `uploads` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nome_file` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
epicfail.html
Codice PHP:
<html> <head> <title>upload</title> </head> <body> Upload fallito.. torna al form </body> </html>
success.html
Codice PHP:
<html> <head> <title>upload</title> </head> <body> Complimenti hai caricato un file </body> </html>
upload.php
Codice PHP:
<?php if(isset($_FILES['file'])){ $target = "uploads/".basename($_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target)){ include "connessione.php"; mysql_query("INSERT INTO uploads values('','$target')"); mysql_close(); header("Location: success.html"); }else{ header("Location: epicfail.html"); } }else{ header("Location: epicfail.html"); } ?>