topical media & game development
professional-sql-06-public-files-upload.php / php
<?php
include '../lib/common.php';
include '../lib/config.php';
// make sure we have all expected parameters
if (!isset(_FILES['file']['error'])
{
// prevent users from traversing outside the base directory
_POST['dir']);
dir . '/' . target, BASEDIR) !== 0)
{
echo '<script type="text/javascript">parent.uploadFailed();</script>';
die();
}
// must move the file to a permanent location
if (move_uploaded_file(target))
{
echo '<script type="text/javascript">parent.refreshFilesList();' .
'</script>';
}
else
{
// there was a problem moving the file
echo '<script type="text/javascript">parent.uploadFailed();</script>';
}
}
// there was a problem uploading the file
else
{
echo '<script type="text/javascript">parent.uploadFailed();</script>';
}
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.