MyBB Community Forums

Full Version: Auto submit attachment form
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi Gents! 
I'm trying to change the behaviour of default MyBB theme attachment upload form. 

What I'm trying is to add something like 

<form action="http://example.com">
    <input type="file" onchange="form.submit()" />
</form>

to avoid two step file upload 
But unfortunately this form is split between many different template files 

Any help?
if you want use my free Plugin
What you are looking for and much more are likely going to be in core with the next MyBB release:
https://github.com/mybb/mybb/pull/4195
(2021-02-03, 07:41 AM)Mostafa.Shiraali Wrote: [ -> ]if you want use my free Plugin

Many thanks. I tried but it doesn't function properly
1.8.24 
Tried on custom and default themes. Besides, upload is still two stage process. 1 select 2 Upload
What you need in bare bone is to add this at the end of your "newthread", "newreply" and "editpost" templates:
<script type="text/javascript">
$("input[name='attachments[]']").on('change',function(){
    $(this).parents('form').trigger('submit');
});
</script>
(2021-02-03, 11:27 AM)effone Wrote: [ -> ]What you need in bare bone is to add this at the end of your "newthread", "newreply" and "editpost" templates:
<script type="text/javascript">
$("input[name='attachments[]']").on('change',function(){
    $(this).parents('form').trigger('submit');
});
</script>

Many thanks. 
This should work indeed, but I tried and this doesn't work . Getting stuck on files select
Stuck means?
What happens?

Keep an eye on your console and see if it says anything ...
(2021-02-03, 11:39 AM)effone Wrote: [ -> ]Stuck means?
What happens?

Keep an eye on your console and see if it says anything ...
only file select is working

Submit is not functional

Or in other words file not getting upload not calling for "insert into post function" and not getting attached

I opened developers console. It's shame but I have to admin I've no idea how to use it. My knowledge is very limited, Yes I can change few lines , but I'm not a coder

P.S Or something maybe missing in my theme template. I have a look
No. No luck on default template as well, but I found an error in custom theme "newthread"
I need a test account with posting privileges, If you can provide ...
(2021-02-03, 11:55 AM)effone Wrote: [ -> ]I need a test account with posting privileges, If you can provide ...

https://alhimika.net/forum/

I will pm you credentials
Pages: 1 2