/    Sign up×
Community /Pin to ProfileBookmark

Calling a input type file

hi

I am trying to call a input from a javascript.
my input file
<input type=”file” name=”file” />

and javascript
<script type=”text/javascript”>
$(document).ready(function(){
// Used for UI widgets and styling samples
$(“#test1”).fileinput();

});
</script>

now the problem is if I add id=”test1″ in the input file the javascript stuff works but then actual thing that input file suppose to pass (File upload info) goes missing.

so I was wondering is there any way I could by pass adding the id part in the input and still call it?

I was thinking some thing like

$(document.forms[0].elements[“file”]).fileinput(); but that’s not working…

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 12.2011 — What do you mean 'goes missing'?
Copy linkTweet thisAlerts:
@akabir77authorApr 12.2011 — What do you mean 'goes missing'?[/QUOTE]

I mean I am using spring frame work to get the info out of FILE input tupe using this in my controler


@RequestParam("file") MultipartFile file

looks like when I submit the form this information doesn't get passed.
Copy linkTweet thisAlerts:
@FangApr 12.2011 — Is it passed correctly without jQuery?
Copy linkTweet thisAlerts:
@akabir77authorApr 12.2011 — yes.

basically if I remove the id from the input it works so if I do this

<input type="file" name="file" id="test"/>

<script type="text/javascript">

$(function(){

// Used for UI widgets and styling samples

$("#test").fileinput();

});

</script>

I get the jQuery stuff working but don't get any data.

is there anyway I could call the input by its name in the javaScript?

I tried using div but get the same result css works but data doesn't get passed.
Copy linkTweet thisAlerts:
@akabir77authorApr 12.2011 — this is the error message i am getting

Required MultipartFile parameter 'file' is not present

I tried calling it by name but same result. looks like the jQuery is doing something here

$(document.getElementsByName("file")).fileinput();
Copy linkTweet thisAlerts:
@FangApr 12.2011 — [I]getElementsByName[/I] is an array
[CODE]$(document.getElementsByName("file")[COLOR="Blue"][0][/COLOR]).fileinput();[/CODE]
Copy linkTweet thisAlerts:
@akabir77authorApr 12.2011 — [I]getElementsByName[/I] is an array
[CODE]$(document.getElementsByName("file")[COLOR="Blue"][0][/COLOR]).fileinput();[/CODE][/QUOTE]


same result.

Resolving exception from handler [org.nipr.docmanagement.roa.web.ROAAddAdminnoticeController@1f61b6a]: org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile parameter 'file' is not present
Copy linkTweet thisAlerts:
@FangApr 12.2011 — Have you tried the example from the plugin?
Copy linkTweet thisAlerts:
@akabir77authorApr 12.2011 — yes. and like i said if the css part works then I don't get the MultipartFile value.

Thanks
×

Success!

Help @akabir77 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...