#1 2013-11-04 21:30:20

lesha
Member
Registered: 2013-10-22
Posts: 11

custom module backend file upload

Hello,

I'm trying to write a custom module. In admin backend I need to upload a file and populate database with data from uploaded file. There is no need to store this file on disk.

I go through tutorial, create a form like 'Edit author' form but with input[type=file] field. Yes, in form tag I added enctype='multipart/form-data' attribute. Form submits as usually but file doesn't upload during submission. As I understand it is necessary to add something special to javascript code to upload file but I can't figure out what exactly.

To be clear here is file upload form view:

<form name="demoFileUploadForm" id="demoFileUploadForm"
	action="<?php echo admin_url() ?>module/demo/file/save_upload"
	method="post"
	enctype="multipart/form-data">

<input id="uploadname" name="filename" class="inputtext" type="file" />

</form>

<div class="buttons">
	<button id="bSavedemoFile" type="button" class="button yes right">
		<?php echo lang('ionize_button_save') ?></button>
	<button id="bCanceldemoFile"  type="button" class="button no right">
		<?php echo lang('ionize_button_cancel') ?></button>
</div>

and toolbox view where upload file form window creates:

<div class="divider">
	<a class="button light" id="uploadFileToolbarButton">
		<i class="icon-upload"></i><?php echo lang('module_demo_button_upload_file'); ?>
	</a>
</div>

<script type="text/javascript">

	$('uploadFileToolbarButton').addEvent('click', function(e)
	{
		ION.formWindow(
			'demoFile',
			'demoFileUploadForm',
			Lang.get('module_demo_title_upload_file'),
			admin_url + 'module/demo/file/upload',
			{
				'width':400,
				'height':75
			}
		);
	});

</script>

Any ideas?

Lesha.

Offline

#2 2016-04-15 19:47:31

fever
Member
Registered: 2016-04-05
Posts: 7

Re: custom module backend file upload

Bump !
I also need help with this problem

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations