0

Need help with code...

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
  • QUOTE (Joe C @ Mar 12 2009, 08:12 AM) <{POST_SNAPBACK}>
    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:

    ...

    Thanks in advance,
    Joe C


    Hey Joe,

    Do you have code that will accept a standard file upload? The design of Uploader is intended to just be a drop in replacement. I'm not familiar myself with vbscript, and haven't written much server side javascript.

    That said, if you can write the server side gunk to accept a standard upload via input type=file, you should be able to drop in uploader, point it at the correct url, specify some variable names, and go!

    helpful?
    lloyd
    0
This forum is locked.

Recent Posts

in Support & General Questions