|
|
## IS52027B: Databases Networks and the web
|
|
|
|
|
|
Term 2
|
|
|
|
|
|
Lab 1
|
|
|
|
|
|
##
|
|
|
|
|
|
http://registermate.doc.gold.ac.uk/
|
|
|
|
|
|
## checking gitlab workflow
|
|
|
|
|
|
## file uploads
|
|
|
|
|
|
create a script to upload a file to igor.
|
|
|
|
|
|
see lecture 11 notes, also
|
|
|
|
|
|
* http://www.w3schools.com/php/php_file_upload.asp
|
|
|
* http://php.net/manual/en/features.file-upload.php
|
|
|
|
|
|
N.B. file permissions on igor: see next slide
|
|
|
|
|
|
## file permissions on igor
|
|
|
|
|
|
* th web user on igor is 'nobody' (verify this yourself with 'ps aux | grep httpd')
|
|
|
* we don't have permission on igor to change group ownership of directories to nobody
|
|
|
* however, your directories will have 'student' as the group, and this includes 'nobody'
|
|
|
* so we just need to change the group permissions
|
|
|
* the command 'chmod g+w' will make it group-writeable (& therefore writeable by the server)
|
|
|
|
|
|
there's some other useful information at https://www.doc.gold.ac.uk/intranet/it/dept-faq.html
|
|
|
|
|
|
## adding album covers to record store
|
|
|
|
|
|
this is an exercise for the lab, to be continued during the week if you don't finish.
|
|
|
|
|
|
we're going to add images to our record store database.
|
|
|
|
|
|
start from the week-8 version that sorrel shared with you.
|
|
|
|
|
|
## backing up the database
|
|
|
|
|
|
this will mean altering the database, not just branching the code.
|
|
|
so back up your database!
|
|
|
|
|
|
* see sorrel's week 8 lectures.
|
|
|
* also see https://dev.mysql.com/doc/refman/5.0/en/mysqldump-copying-database.html
|
|
|
|
|
|
## alter database
|
|
|
|
|
|
* add a column for image (name) to the database
|
|
|
|
|
|
## modify form
|
|
|
|
|
|
need to add
|
|
|
|
|
|
* enctype="multipart/form-data" to the form.
|
|
|
* a hidden field for MAX_FILE_SIZE"
|
|
|
* input type="file"...
|
|
|
|
|
|
## uploads directory
|
|
|
|
|
|
create an uploads directory
|
|
|
change permissions so it's writeable by the web server process
|
|
|
|
|
|
## handling the upload
|
|
|
|
|
|
add code to handle the image upload (see week 11 slides)
|
|
|
|
|
|
## register the image with the database
|
|
|
|
|
|
add the image to the database query
|
|
|
|
|
|
## display the image
|
|
|
|
|
|
display the image in the record listings
|
|
|
|
|
|
## cookies
|
|
|
|
|
|
create a simple test to show you can use cookies.
|
|
|
|
|
|
see lecture 11 notes, also
|
|
|
|
|
|
* http://www.w3schools.com/php/php_cookies.asp
|
|
|
* http://php.net/manual/en/features.cookies.php
|
|
|
|
|
|
## sessions
|
|
|
|
|
|
create a simple test to show you can use sessions.
|
|
|
|
|
|
see lecture 11 notes, also
|
|
|
|
|
|
* http://www.w3schools.com/php/php_sessions.asp
|
|
|
* http://php.net/manual/en/session.examples.basic.php
|
|
|
|