$uploadDir = dirname(__FILE__) . '/files/';
$uploadFile = $uploadDir . basename($_FILES['Filedata']['name']);if ($_POST['submit'] != '') {
// 1. submitting the html form
if (!isset($_GET['jqUploader'])) {
// 1.a javascript off, we need to upload the file
if (move_uploaded_file ($_FILES[0]['tmp_name'], $uploadFile)) {
// delete the file
// @unlink ($uploadFile);
$html_body = '<h1>File successfully uploaded!</h1><pre>';
$html_body .= print_r($_FILES, true);
$html_body .= '</pre>';
} else {
$html_body = '<h1>File upload error!</h1>'; switch ($_FILES[0]['error']) {
case 1:
$html_body .= 'The file is bigger than this PHP installation allows';
break;
case 2:
$html_body .= 'The file is bigger than this form allows';
break;
case 3:
$html_body .= 'Only part of the file was uploaded';
break;
case 4:
$html_body .= 'No file was uploaded';
break;
default:
$html_body .= 'unknown errror';
}
$html_body .= 'File data received: <pre>';
$html_body .= print_r($_FILES, true);
$html_body .= '</pre>';
}
$html_body = '<h1>Full form</h1><pre>';
$html_body .= print_r($_POST, true);
$html_body .= '</pre>';
} else {
// 1.b javascript on, so the file has been uploaded and its filename is in the POST array
$html_body = '<h1>Form posted!</h1><p>Error:<pre>';
$html_body .= print_r($_POST, false);
$html_body .= '</pre>';
}
myHtml($html_body);
} else {
if ($_GET['jqUploader'] == 1) {
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 2. performing jqUploader flash upload
if ($_FILES['Filedata']['name']) {
if (move_uploaded_file ($_FILES['Filedata']['tmp_name'], $uploadFile)) {
// delete the file
// @unlink ($uploadFile);
return $uploadFile;
}
} else {
if ($_FILES['Filedata']['error']) {
return $_FILES['Filedata']['error'];
}
}
}
}
// /////////////////// HELPER FUNCTIONS
function myHtml($bodyHtml)
{ </script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货