I really need help with my problem
The idea is this one , One user wants to upload a file a pdf or .doc file, and that file can be displayed in another php page.
where a second user can download the specific file.
---Example----
Name Download
book.pdf yes
book2.doc yes
----------------------
For that I need two php files
first the Upload.php
Code: Select all
<h1>Files</h1>
<form action="viewfiles.php" method="post" enctype="multipart/form-data">
<p><strong>Upload files:</strong><br />
<input type="file" name="file" size="700" id="file"></p>
<p>
<input type="submit" value="Upload" />
</p>
Code: Select all
if ($_FILES)
{
$name = $_FILES['file']['name'];
switch($_FILES['file']['type'])
{
case 'application/pdf': $ext = 'pdf'; break;
case 'application/msword': $ext = 'doc'; break;
default: $ext = ''; break;
}
if ($ext)
{
echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">';
echo "<tr>
<th>Name</th>
<th>Download</th>
</tr>";
$n = "application.$ext";
move_uploaded_file($_FILES['file']['tmp_name'], $n);
echo '<tr>';
foreach ($name as $n){
echo "</tr>";
}
echo '<td align="center">'."$name <a href='$n'>yes</a>" . '</td>';
}
else echo "'$name' This file is not a pdf or doc";
}
else echo "File not uploaded";
Array ( [file] => Array ( [name] => book.pdf [type] => [tmp_name] => [error] => 1 [size] => 0 ) )
'book.pdf' is not a pdf or doc.
Can anyone help me to display what I want the table and the download file
thanks