/    Sign up×
Community /Pin to ProfileBookmark

Access file in iFrame?

I have a form that, when submitted, uploads a file into an invisible iframe on the same page. Does anyone know of a way that I can then access the filename of this file using javascript?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@mataichiJul 07.2009 — After you upload the file, you can use javascript to add a hidden field that holds the name of the file.

I do something similar for one of my projects.
Copy linkTweet thisAlerts:
@benkymaauthorJul 07.2009 — That's cool. Can you explain how to do this?
Copy linkTweet thisAlerts:
@mataichiJul 08.2009 — Ok, so I made a few assumptions.

Here is a basic outline of how I handle this issue.

I assume you have a page and you are uploading a file. You want to upload the file, but not refresh the entire page, so you use an invisible iframe to do this.

So your <form> has some action like action="SaveFile.asp" which is where the file is actually upload to your server.

After I save the file here I call a javascript function from my asp page like this....
[CODE]<script language="javascript" type="text/javascript">
window.top.window.stopUpload('<&#37;=thisFileNm%>');
</script> [/CODE]


Then from the stopUpload() function, I can create a hidden element with a value of the file name that I passed and insert it into the document somewhere.
×

Success!

Help @benkyma 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 5.16,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...