stop/cancel file upload in html? - html

If i have a file upload and i click on something to cancel it, how do i stop the upload? I tried doing $('form').remove() and it appears to continue uploading. Maybe i should put it in an iframe and destroy the iframe? then i need to figure out how to reload it hmm.
Are there any known cross platform ways?
-edit- btw this must be done in pure html and js, no flash or silverlight.

Use Flash to upload the file, then you have a lot more control to include a progress bar and allow the client to cancel.
Here's a commonly used JS wrapper, but I don't know if this specific one has a cancel api:
http://code.google.com/p/swfupload/

Related

Close a game in Godot

I'm creating a web game using Godot.
For close the game, i tried to use `get_tree().quit()`.
If I use it on the IDE, it works. When i tried it on my server (after exported the project) it doesn't work.
I'm sure that Exporting setting are okay.
How can I close the game?
And, how can I add an hypertext link (similar to html `` tag)?
Thanks for your answer and sorry for my bad English
Exit the game
On the web, using
get_tree().quit()
Should work. That is, it should stop the runtime. The game will not continue running. It does not close the browser tab. In fact, browsers have restriction on scripts closing tabs.
Note: Make sure you are using Godot 3.2.3 or newer (see #39604). I tried it, it works.
Making a link
You can a LinkButton, which is a button that looks like an hyperlink. And you want to connect its "pressed" signal to a script where you use OS.shell_open, for example:
OS.shell_open("https://example.com")
Note: This result in a new tab in web exports. On the desktop it opens the default browser.
Navigating the browser
Since you ask about closing the game, and about making a link, I'll venture to guess that what you actually want is to navigate (leaving the game and going to another page), you can accomplish that with JavaScript.eval, for example:
JavaScript.eval("window.location.href='https://example.com'")
Note: This can only work on a web export.
Detecting Web Build
You can use OS.get_name to identify the platform.
For example, you can do this:
if OS.get_name() == "HTML5":
JavaScript.eval("window.location.href='https://example.com'")
else:
OS.shell_open("https://example.com")
Which will navigate the browser if this is a web build, but if it isn't, it will try to open the default browser.

How to embed video on html that will not play on browser?

I know this question is simple and kind of silly but I really need to get an answer. I am doing some kind of family videos put together and I want that to be on one page or like an HTML file. but when I embed/link a directory file of video to the html it will play on the browser. Is there any way that when I embed a link it will just ask what application to open and will open on that video player that I selected? I'm not really that techie but I really need to make an offline HTML to organize my stuff. thank you so much in advance.
is there any way that when i embed a link it will just ask what application to open and will open on that videoplayer that i selected
Not all browsers do this, but many will. One way to look at this is that the browser in this case is the desired application for viewing that video. (Often times, the user didn't make this choice of course, it was made for them.)
There are a couple ways around this. One way is to add the download attribute to your anchor element:
<a href="video.webm" download>Download the video</a
This will suggest to the browser that the video should be saved to local disk, and not just immediately opened.
A second method is to use an M3U file. All you need in your file is something like this:
#EXTM3U
https://example.com/video.webm
These tend to open up in the default player. Just keep in mind that not everyone has such a player installed.
You have to make your video files downloadable by creating a download link to it. This will give the option of either open in browser or save to local disk.

Improve load time for a html page with flash

I have a basic html page and a big flash file I need to embed. I would like to allow the user to click on the links until the flash files loads.
I was thinking of two ways to do this
1. use an iframe and put the flash file in there
2. use jquery to load and append the flash file to an internal div
Is this the way to go ? Are there better solutions ?
I would suggest that jQuery is the best way to add the element to the page.
There are many plugins for jQuery which make it easy to achieve. One of the better ones I have found can be found at http://jquery.thewikies.com/swfobject/

HTML input type = file in Adobe AIR does not present file browser

So the good old HTML file uploader tag only presents a browse button (without associated text input) when rendered in a HTML based Adobe AIR application. Upon clicking the browse button, nothing seems to happen. I would expect a popup window so I can select a file. I've seen examples of people using Javascript to call the AIR runtime to get a file and upload it, but I was wondering if anyone knew a complete HTML/Javascript way of doing this with AIR.
thanks
Actually, this does work. I somehow managed to stop this from working, probably through a combination of cloning that part of the DOM elsewhere.

How do i allow the user to select more than one file for upload?

Gmail just released an update to their interface allowing the user to select more than one file for upload by using the CTRL-button. How do they do that? You can read about the new feature and see a screen shot here:
http://gmailblog.blogspot.com/2009/02/updates-to-attachments-multi-select-and.html
You will need to find flash-based sollution, like Google did with Gmail. You can try this jQuery plugin that offers exactly that: jQuery File Upload Plugin
Adobe Flash Player.
Here's a good library that I used: SWFUpload
Of course this is a JavaScript library, and not a jQuery plug-in, making it much more portable.
Take a look at RFC 1867 It defines how to upload files over HTTP using the multipart/mixed encoding. You can use the Apache Commons FileUpload library to do this in Java. I don't know how Google does it, but you can manage the multiple selects with JavaScript processing in your page.
Not the method Gmail uses, but the following link, combined with some jquery you can allow an unlimited number of files to be uploaded at the same time: Link
Google isn't using Flash, but actually some clever javascript (well, that IS what they're all about it seems :-) ). Using javascript and css, you can create a file chooser that lets the user select the file to upload. Then, you use a hidden iframe. The act of posting the form with your upload file targets the hidden iframe so that the result returned from the server on success goes into that hidden iframe. Using javascript, monitor the document body of that iframe to know when the file is uploaded.
This link appears to be a quick example of the basic concept: http://www.seemysites.net/projFolder/uploader/