php web
stuff related to writing php web portals
2 2008-04-15 functions of script mcb_retreat/php/symp_reg.php
connect to postgresql db
insert stuff into db
a form with a file attached. enctype="multipart/form-data" is a required attribute for this kind of form:
<form enctype="multipart/form-data" method="post" name="abstract" action="<?php echo $_SERVER['PHP_SELF'];?>">
file is in the _FILES array. $abs_file=$_FILES['abs_file']["tmp_name"];. tmp_name and name are different. The former is the temporary file name including path on the server. The latter is the original file name on the client.
upload a file. move_uploaded_file($abs_file, $target_path);
string operation. trim() strtolower(). concatenation by dot (.).
encode file data and submit into db column (type=text). $abs_file_data = base64_encode($abs_binary); pg_escape_bytea is a similar function for binary column type (bytea).