Topic: Trying to make a user punbb gallery...
$_GET['id'] = $id;
if (empty($id) || $id < 2) {
message('Bad request.');
}
if ($cookie['is_guest'] || $cur_user['id'] != $id && $cur_user['status'] < PUN_MOD) {
message('You are not allowed to access this page.');
}
if (isset($_POST['form_sent']))
{
$uploaded_file = $_FILES['image'];
// Make sure the upload went smooth
switch ($_FILE['image']['error'])
{
case 1: // UPLOAD_ERR_INI_SIZE
case 2: // UPLOAD_ERR_FORM_SIZE
message('Too large.');
break;
case 3: // UPLOAD_ERR_PARTIAL
message('Partial upload.');
break;
case 4: // UPLOAD_ERR_NO_FILE
message('No file.');
break;
default:
// No error occured, but was something actually uploaded?
if ($_FILE['image']['size'] == 0)
message('No file');
break;
}
if (is_uploaded_file($uploaded_file['tmp_name']))
{
$ok_filetypes = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
if (!$_FILES['image']['error'] && $_FILES['image']['size'] > $pun_config['o_avatars_size'] * 1024) {
message('Sorry, but the attached file is too large. Please reduce the size of it\'s contents.'); // #err
}
$filename = (!$_FILES['image']['error'] ? substr(basename($_FILES['image']['name']), -30 ) : '');
$x = strtolower(substr($_FILES['image']['name'], -3));
if ($filename && !in_array($x, $ok_filetypes)) {
message('Sorry, the filetype you have tried to upload is not allowed.');
}
$uniq = $id.'_'.substr(md5(uniqid(rand())), 0, 10);
// This is line is commented for a reason
// $ext = strtolower( substr($_FILES['attached']['name'], -3));
move_uploaded_file($_FILES['image']['tmp_name'], $pun_config['o_base_url'].'/members/images/'.$uniq);
// Put the stuff in the db
$db->query('INSERT INTO '.$db->prefix.'gallery (user_id, url, caption) VALUES(
\''.addslashes($id).'\',
\''.addslashes($uniq).'\',
\''.addslashes($_POST['caption']).'\'
)') or error('Unable to insert picture into db', __FILE__, __LINE__, $db->_error());
redirect('profile.php?id='.$id, 'Your Picture has been added! Redirecting...');
}
I get the message: "No File" whenever I try to upload an image but the problem is is that there is a file...Does anyone see an error in my syntax?