Ciao a tutti,
sto provando a realizzare un modulo che mi consenta l'upload dei file sul server. Mi sono basato sul tutorial presente qui.
Il form è così strutturato:
<form enctype="multipart/form-data" action="add.php" method="POST">
Name: <input type="text" name="name">
E-mail: <input type="text" name = "email">
Phone: <input type="text" name = "phone">
Photo: <input type="file" name="photo">
<input type="submit" value="Add">
</form></body>
Il codice php è invece il seguente:
Codice PHP:
<?php
$target = "images/";
$target = $target . basename( $_FILES['photo']['name'];
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);
mysql_connect("host", "user", "pws") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')");
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
echo "Sorry, there was a problem uploading your file.";
?>
Dopo aver compilato il form e dato l'ok per l'upload del file, compare il seguente messaggio d'errore:
Parse error: syntax error, unexpected T_VARIABLE in ... on line 14
Vale a dire qui:
Codice PHP:
$name=$_POST['name'];
Il sito è ospitato su Tophost. Leggendo il loro supporto, pare che la direttiva REGISTER_GLOBALS sia settata su OFF. Questo dovrebbe cambiare qualcosa rispetto a come è stato scritto il codice?
Grazie per le risposte.
Luca