Hey all, I'm trying to implement a drag and drop file upload for a client. The examples here are nice, but the site I'm working on doesn't support php. So, I need some help in converting the sample php from here to either vbscript or javascript. Any help would be greatly appreciated. The code I got from the BP example is:
upload.php
==============================================
$uploadErrors = array(
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder.',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk.',
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension.',
);
header("Content-type: text/plain");
echo "{\n";
echo " 'post_variables': {\n";
foreach ($_POST as $k => $v) {
echo " " . $k . ": '" . $v . "'\n";
}
echo " },\n";
echo " files: [\n";
for ($x = 0; $x < sizeof($_FILES); $x++) {
echo " {\n";
$ec = $_FILES[$x]['error'];
if($ec !== UPLOAD_ERR_OK)
{
if(isset($uploadErrors[$ec])) {
echo " error: '" . $uploadErrors[$ec] . "',\n";
} else {
echo " error: 'unknown error',\n";
}
}
echo " size: " . $_FILES[$x]['size'] . ",\n";
echo " name: '" . $_FILES[$x]['name'] . "',\n";
echo " md5: '" . md5(file_get_contents($_FILES[$x]['tmp_name'])) . "'\n";
echo " },\n";
}
echo " ]\n";
echo "}\n";
==============================================
Thanks in advance,
Joe C
by
1 Reply