Add to the login assignment three more pages
1) Upload a file.
Check to see if the person is logged in.
Check to see if it's a reasonable file extension
Copy it to the database.
2) List the files
Check to see if the person is logged in
Show them a list of uploaded files. Each filename is a link the show page.
3) Show/Play a file
Check to see if they're logged in.
Show the file.
For these new pages, you cannot get security through header-location things.
You will probably need to use the alternative if syntax.
Due Thr Mar 10
Remember: The data for the pic must be longblog.
Also, printing a longblob probably doesn't do what you want. But this might be useful:
mysql> select id, filename, length(pic) from pics;
Hints: I used the following lines in my implementation (which was PDO)
$data = file_get_contents($_FILES['file']['tmp_name']);
...
$stmt = $dbh->prepare("insert into pics (filename, pic) values (?,?);");
...
if ($stmt->execute(array($_FILES['file']['name'], $data))) {
I used the following lines in my showpic
$stmt = $dbh->prepare("SELECT id, filename, pic, mimetype FROM pics where id = ?");
...
$row = $stmt->fetch();
...
header("Content-type:" . $row['mimetype']");
....
print($row['pic']);