The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
|
#1
|
|||
|
|||
Upload Image from Admincp
Okay, so I have been upgrading this mod https://vborg.vbsupport.ru/showthrea...hlight=vbmusic for awhile now. I was complete but not happy with it. There was some things I wanted to change.
To add a album from the admincp I didn't want just a html link to add to the database. I wanted to give the admin the option to upload a image where it save's the file to the server and inserts the link into the database. I can get the path to show up in the database, but the file doesn't show up in the correct folder. This is my code for creating a album. Please any assistance would be greatly appreciated. Code:
$tables = array('music_album' => 'Music Album Image'); $itempath = $vbulletin->GPC['table'] . 'path'; //########### ADD & EDIT ALLBUM #############\\ // ###################### Start Do Upload ####################### if ($_POST['do'] == 'doupload') { $vbulletin->input->clean_array_gpc('f', array( 'upload' => TYPE_FILE, )); $vbulletin->input->clean_array_gpc('p', array( 'names' => TYPE_STR, 'artistid' => TYPE_UINT, 'info' => TYPE_STR, 'image' => TYPE_STR, 'catid' => TYPE_UINT, 'length' => TYPE_UINT, 'year' => TYPE_UINT, 'total_songs' => TYPE_UINT )); $vbulletin->input->clean_array_gpc('r', array( 'id' => TYPE_INT, 'artistid' => TYPE_UINT )); if (empty($vbulletin->GPC['names']) OR empty($vbulletin->GPC['image'])) { print_stop_message('please_complete_required_fields'); } //if (file_exists('./' . $vbulletin->GPC['image'] . '/' . $vbulletin->GPC['upload']['name'])) //{ // print_stop_message('file_x_already_exists', htmlspecialchars_uni($vbulletin->GPC['upload']['name'])); //} require_once(DIR . '/includes/class_upload.php'); require_once(DIR . '/includes/class_image.php'); $upload = new vB_Upload_Image($vbulletin); $upload->image =& vB_Image::fetch_library($vbulletin); $upload->path = $vbulletin->GPC['image']; $names = $vbulletin->GPC['names']; $artistid = $vbulletin->GPC['artistid']; $info = $vbulletin->GPC['info']; $image = $vbulletin->GPC['image']; $catid = $vbulletin->GPC['catid']; $length = $vbulletin->GPC['length']; $year = $vbulletin->GPC['year']; //if (!($imagepath = $upload->process_upload($vbulletin->GPC['upload']))) // { // print_stop_message('there_were_errors_encountered_with_your_upload_x', $upload->fetch_error()); //} define('IMAGE_UPLOADED', true); $_POST['do'] = 'insert'; } // ###################### Start Upload ####################### if ($_REQUEST['do'] == 'upload') { print_form_header('vbmusic', 'doupload'); print_table_header('Add Album'); print_upload_row($vbphrase['filename'], 'upload'); print_input_row('Album Title', names, ''); print_select_row('Artist', 'artistid',fetch_artist_array($artsid)); print_textarea_row('Album Info', 'info', ''); print_select_row('Album Genre', 'catid',fetch_category_array($catid)); print_input_row('Length', 'length', ''); print_input_row('Year', 'year', ''); print_input_row('Total Songs', 'total_songs', ''); print_input_row($vbphrase["{$itemtype}_file_path_dfn"], 'image', 'vbmusic/photos/', 'upload'); //print_input_row('Album Image Path',image, $vbulletin->options['vbmusic_image_path'],'image' ); print_submit_row($vbphrase['upload']); } // ###################### Start Insert ####################### if ($_POST['do'] == 'insert') { $vbulletin->input->clean_array_gpc('p', array( 'imagespath' => TYPE_STR, 'names' => TYPE_STR, 'artistid' => TYPE_UINT, 'info' => TYPE_STR, 'image' => TYPE_STR, 'catid' => TYPE_UINT, 'length' => TYPE_UINT, 'year' => TYPE_UINT, 'total_songs' => TYPE_UINT )); //if (!$vbulletin->GPC['image'] OR (!$vbulletin->GPC['names']) //{ // print_stop_message('please_complete_required_fields'); //} //if ($vbulletin->GPC['table'] == 'smilie' AND $db->query_first("SELECT smilieid FROM " . TABLE_PREFIX . $vbulletin->GPC['table'] . " WHERE BINARY smilietext = '" . $db->escape_string($vbulletin->GPC['smilietext']) . "'")) //{ if (IMAGE_UPLOADED AND file_exists($imagepath)) { // if the image is being uploaded zap it unlink($imagepath); } // this smilie already exists //print_stop_message('smilie_replace_text_x_exists', $vbulletin->GPC['smilietext']); //} if (IMAGE_UPLOADED !== true) { // we are adding a single item via the form, use user input for path $imagepath =& $vbulletin->GPC['imagespath']; } /*insert query*/ $db->query_write(" INSERT INTO " . TABLE_PREFIX . "music_album (`name`, `artistid`, `info`, `image`, `catid`,`length`,`year`,`total_songs`)VALUES('" . addslashes($names) . "', '$artistid', '" . addslashes($info) . "', '" . addslashes($image) . "', '$catid','" . addslashes($length) . "','" . addslashes($year) . "','" . addslashes($total_songs) . "')"); //build_image_cache($vbulletin->GPC['table']); //build_image_permissions($vbulletin->GPC['table']); //if ($itemtype == 'avatar') //{ // print_stop_message('need_to_rebuild_avatars'); //} //else //{ exec_header_redirect("vbmusic.php?do=updatealbum"); exit; } //} |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|