PDA

View Full Version : Admincp Upload Form


Ziki
02-20-2012, 06:50 PM
Hey guys,

I created an upload form for my admincp script but I am having problems with it. When I try to var_dump($_FILES) it only returns array(1) { ["image"]=> NULL } and no file is being uploaded. $vbulletin->GPC['image']['name'] is empty as well. My destination folder is chmodded 777. Any help? Below is the code. thanks!

if ($_REQUEST['do'] == 'editrelease') {
$vbulletin->input->clean_array_gpc('r', array(
'releaseid' => TYPE_STR
));
$release = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "releasesystem_releaseinfo WHERE releaseid = '". $vbulletin->GPC['releaseid'] ."'");
print_cp_header("Edit Release ". $release['title']);
print_table_start();
print_table_header("Edit Release ". $release['title'], 2);
print_form_header('releasesystem_admin', 'editreleasedo');
print_upload_row("Image", 'image');
construct_hidden_code('releaseid', $vbulletin->GPC['releaseid']);
print_submit_row("Save Release", 0, 2);
print_table_footer();
}

if ($_REQUEST['do'] == 'editreleasedo') {
$vbulletin->input->clean_array_gpc('p', array(
'releaseid' => TYPE_STR,
));
$vbulletin->input->clean_array_gpc('f', array(
'image' => TYPE_FILE,
));

if ($vbulletin->GPC['image'] != "") {
$uploaddir = './images/releases/';
$unique = time();
$newfilename = $unique . "-" . $_FILES['image']['name'];
$largepic = $uploaddir . basename($newfilename);
move_uploaded_file($_FILES['image']['tmp_name'], $largepic);

//here is the db query
}


//redirect message
}

--------------- Added 1329769031 at 1329769031 ---------------

Nvm, I figured it out.This:

print_form_header('releasesystem_admin', 'editreleasedo');

Should be this:

print_form_header('releasesystem_admin', 'editreleasedo', 1, 1);