السلام عليكم
قمت بكتابة كود registration form ... والكود يحتوي على سكربت لرفع ملف
لكن تواجهني مشكلة ظهور هذه الرسالة
"The file you attempted to upload is not allowed."
هذا هو الكود :
index.php
<html> <body> <center> <h3>Registration</h3> <form action="./upload.php" method="post" enctype="multipart/form-data"> <table> <tr> <td>First Name<td><input name="firstname" type="text" /></td></br></td> </tr> <tr> <td>Last Name<td><input name="lastname" type="text" /></td></br></td> </tr> <tr> <td>e-mail<td><input name="email" type="text" /></td></br></td> </tr> <tr> <td>Phone<td><input name="phone" type="text" /></td></br></td> </tr> <tr> <td>Institution <td><input name="institution" type="text" /></td></br></td> </tr> <tr> <td>Specialist <td><input name="specialist" type="text" /></td></br></td> </tr> <tr> <td>Do you require accommodation? <td><Input type = 'Radio' Name ='accommodation' value= 'Yes'>Yes <Input type = 'Radio' Name ='accommodation' value= 'No'>No </td> </td></tr> <tr> <td>Grade <td><select name="grade"> <option value="student">Student</option> <option value="intern">Intern</option> <option value="senior">Senior House Officer</option> <option value="registrar">Registrar</option> <option value="specialist">Specialist</option> <option value="consultant">Consultantant</option… </select></td> </td></tr> <tr> <td>Participation Type <td> <input type="checkbox" name="P" value="Paper" />Paper</br> <input type="checkbox" name="W" value="Workshop" />Workshop</br> <input type="checkbox" name="Pr" value="Presentation" />Presentation</br> <input type="checkbox" name="A" value="Attendance" />Attendance</td> </td> </tr> <tr> <td> </br> <label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> </br> </br> </td> </tr> <tr> <td> <input type="Submit"> </td> </tr> </table> </form> </center> </body> </html>
upload.php
<?php
// Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.docx','.txt'); // These will be the types of file that will pass the validation.
$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = './uploads/'; // The place the files will be uploaded to (currently a 'files' directory).
$filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
$filename = time() .'_'. $filename;
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; // It worked.
else
echo 'There was an error during the file upload. Please try again.'; // It failed :(.
// Get values from form
$firstname=$_POST['lastname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$institution=$_POST['institution'];
$specialist=$_POST['specialist'];
$accommodation=$_POST['accommodation'];
$grade=$_POST['grade'];
$P=$_POST['P'];
$W=$_POST['W'];
$Pr=$_POST['Pr'];
$A=$_POST['A'];
// Insert data into mysql
$link=mysql_connect ("localhost","root","123456") or die ("Connection Failed !!");
echo "<br>";
echo "<br>";
if((firstname && lastname && email && Institution && Specialist)<>""){
$sql = 'INSERT INTO `jml-reg` (`id`, `firstname`, `lastname`, `email`, `phone`, `institution`, `specialist`, `accommodation`, `grade`, `paper`, `workshop`, `presentation`, `attendance`) VALUES (NULL, \'trt\', \'dfdf\', \'fdfd\', \'545\', \'dfdf\', \'fdfd\', \'Yes\', \'sfd\', \'dsds\', \'dsd\', \'dsd\', \'dsds\');';
mysql_query($sql);
mysql_close();
}
?>قمت برفع الملفات المسموحة ولكن تظهر لي هذه الرسالة


