Forum Moderators: coopster
in upload page I save the file with these codes:
$uploadDir = 'file:///C:/wamp/www/newweb/ExamPapers/';
if(isset($_POST['upload']))
{
$fileName = $_REQUEST[subject_name];
$tmpName = $_FILES['userfile']['tmp_name']; //path to the file
$fileSize = round((($_FILES['userfile']['size'])/1024/1024), 2);
$fileType = $_FILES['userfile']['type'];
// get the file extension first
$ext = ".pdf";
// make the file name
$uniqueName = $_REQUEST[subject_code] ."_". $_REQUEST[semester] ."_". $_REQUEST[year];
//the unique file name for the upload file
$filePath = $uploadDir . $uniqueName . $ext;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Erro uploading file";
exit;
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
*************************************************************************
and in search page, I refer to them this way:
while ($row = mysql_fetch_assoc( $result ))
{
$sc = $row['Subject_code'];
$sn = $row['Subject_name'];
$dep = $row['Department'];
$sem = $row ['Semester'];
$y = $row['Academic_Year'];
$size = $row['file_size'];
$link = $row['file_path'];
print("<tr>");
print("<td>$sc</td>");
print("<td>$sn</td>");
print("<td>$dep</td>");
print("<td>$sem</td>");
print("<td>$y</td>");
print("<td>$size</td>");
print("<td><a href = \"$link\" target=\"_blank\"><img src=\"../Images/View.png\" alt=\"View exam paper\"></a></td>");
print("</tr>");
}
can anyone tell me whats the problem with opening the file?