Yarnell Posted March 11, 2021 Posted March 11, 2021 Good evening all. I'd like to add a simple upload form to the digital options tab when creating/editing a product. In the event that one forgets to upload a file first, it would suck having to navigate to the upload section and loose all the data. Anyone have any ideas on what would be the best approach to do this?
bsmither Posted March 11, 2021 Posted March 11, 2021 In other words, you would like to have a "Drop Zone" on the Digital tab, like the one on the Images tab? We can add that as a feature request in the GitHub.
Yarnell Posted March 11, 2021 Author Posted March 11, 2021 Yea, I didn't even think to use the drop zone, that would be even better... I was able to figure out how to add the regular upload form though. For anyone interested. I placed this code above the Custom File Path in /admin/skins/default/templates/products.index.php <fieldset> <legend>{$LANG.common.upload_files}</legend> <p>Select image files to start uploading. There is a max filesize of {$upload_max_filesize}.</p> <input name="file" id="uploader" type="file" class="multiple"> <input type="submit" name="submit_cont" value="{$LANG.common.upload}"> </fieldset> And this code right below global $lang; in /admin/sources/products.index.inc.php $select_button = false; $mode = FileManager::FM_FILETYPE_DL; $path = "public"; $fm = new FileManager($mode, $path); if (!empty($_FILES) && Admin::getInstance()->permissions('filemanager', CC_PERM_EDIT)) { if ($fm->upload()) { if ($fm->buildDatabase()) { $GLOBALS['main']->successMessage($lang['filemanager']['notify_list_update']); } else { $GLOBALS['main']->errorMessage($lang['filemanager']['error_list_update']); } if (count($_FILES)>1) { $GLOBALS['main']->successMessage($lang['filemanager']['notify_files_upload']); } elseif ($_FILES['file0']['size']>0) { $GLOBALS['main']->successMessage($lang['filemanager']['notify_file_upload']); } } else { $GLOBALS['main']->errorMessage($lang['filemanager']['error_file_upload']); } } You will need to change the $path to where you store your files.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.