To access an uploaded file, you use $_FILES['pic1'] rather than $_POST['pic1']. Also, make sure the correct enctype is set in the form or you may have problems uploading:
PHP Code:
<form name="myform" enctype="multipart/form-data" method="post" action="script.php">
$_FILES has the following elements you can then access:
PHP Code:
$_FILES['userfile']['name'] // the original name of the file
$_FILES['userfile']['type'] // eg image/jpeg
$_FILES['userfile']['size'] // filesize
$_FILES['userfile']['tmp_name'] // the tmp name of the uploaded file on the server
$_FILES['userfile']['error'] // an error code - 0 means no error, 4 means no file uploaded, etc
I can't test it directly but I think you should be able to do:
PHP Code:
$pic1 = addslashes(fread(fopen($_FILES['userfile']['tmp_name'], "r")));
Alternatively you may need to move the file to another directory where you an access it, upload it to the database then unlink() the file on the server (you might need to do this if you experience open_basedir errors), you can move the file using
move_uploaded_file().
This section on
handling file uploads on php.net is very useful as is the page on
error codes.