// Display upload status and images
//Uploading files requires defining enctype. In order to display images, set the target to uploadframe
function uploadimg(theform){
//Submit Form
theform.submit();
//Display upload status in showimg
setStatus ("Loading. ..","showimg");
}
//Upload status function
function setStatus (theStatus, theObj){
obj = document.getElementById(theObj);
if (obj ){
obj.innerHTML = "
" + theStatus + "
";
}
}
process_upload .php provides file upload function:
Copy code The code is as follows:
//Provide pictures Type check
$allowedtypes = array("image/jpeg","image/pjpeg","image/png", "image/x-png","image/gif");
//File Storage directory
$savefolder = "images";
//If there are files uploaded, start working
if (isset ($_FILES['myfile'])){
// Check whether the uploaded file conforms to the $allowedtypes type
if (in_array($_FILES['myfile']['type'],$allowedtypes)){
if ($_FILES['myfile']['error'] == 0){
$thefile = "$savefolder/".$_FILES['myfile']['name'];
//Upload files through move_uploaded_file
if (!move_uploaded_file($_FILES[ 'myfile']['tmp_name'], $thefile)){
echo "There was an error uploading the file.";
}
else{
?>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">