I have an upload function on a page that uploads any attached file.
Below the attachment button, i have a list of uploaded files that fails to refresh and display the latest attached file.
When a small file is added, by the time my refresh function kicks in, it has already uploaded, and so my page refreshes and displays the upload.
problem is, whn i upload a larger file, the refresh kicks in BEFORE the file is uploaded, so no new file is displayed.
Is there a way to wait for the upload and then update the list?
Normally you will post the form with the file to the server, and the server will respond with the updated page when the upload is complete.
If you use a different way of uploading files, you have to use whatever method that solution provides for signalling when the upload is complete. Unless you are using a component (ActiveX/Java/Silverlgith) to do the upload, there is still a form somewhere that is posted to the server, and the server still returns a response when the upload is done.
Related
I have a url that when entered in to the browser generates a XML file and automatically downloads it to the computer.
Is there a way of doing this inside node.js?
I have tried various fetch ideas but they just download the originating page and not the file that is generated.
UPDATE FOR CLARITY: The page I'm getting the file from is doing a <FORM METHOD="POST" ACTION="catalogDownload.asp?a=a"> When I hit submit (or use the URL with the search parameters) it will download a file called stuff.XML to the computer. It is the file stuff.XML that I would like to capture programmatically, ideally (but not essentially) in node.js. My main goal at the moment is to download the file without manual intervention.
I am writing a single page application where the user can upload photos. But I am not clear about a situation in which while user is uploading multiple photos, he closes the browser. Now when he logs in again, the browser should automatically resume the upload from the last uploading image. Is this possible? How?
I cannot store the image in local storage and upload since the image
size can go beyond the local storage capacity.
I cannot store the file path and resume by using the file path.
Since the browser security won't allow me to.
When you are working with an SPA and the browser is closed the data in the SPA is lost. Even if you want them to resume uploading(which browser security won't allow) using the path there are 2 case scenario:
1)Does the file actually exist in the old path(No)
2)What if the user deleted or moved the file.
Anyways this should not be done using browser. Better to use a tool with 3rd party. like if you shut down the client, then the client will stop sending data to the server.
If you want to upload large files on a regular basis and not have the process be interrupted by people forgetting that their browser is uploading in another tab and quitting, then you might consider using a stand-alone upload tool (http://www.flickr.com/tools/uploadr/)
However It can be achieved by designing a special type of browser.
I am using Node and AWS javascript SDK. The workflow is like this:
Web app calls an API to get a few files created and downloaded to EBS,then these files are uploaded to s3. Depending on file sizes etc, it is possible that one file starts uploading while another uploading hasn't finished yet.
Is this ok to s3?Thanks.
it is possible that one file starts uploading while another uploading hasn't finished yet
It is normal, but this means asynchronous upload. Synchronous loading means, that you start to upload next file after previous one was uploaded.
IMO, the best way is to run async (batch) uploading, collect responces from S3 and then send back URIs of uploaded files.
In my app I need to upload an image to the server, and user needs to preview the file before uploading it. So do it like this:
Show an image preview before upload
But after posted to server and there may be some errors, I have to return it back to client. Of course, the preview image loaded on client was lost, now I want to load it back again but I can't find the file to load using javascript. I have tried some ways:
$("file-input-selector").prop("files")
or:
document.getElementById("file-input-id").files
These only work when I select another image on the machine. After posted back from server both ways show 0 files
Is there another way to get the file after posted to the server back?
I've to upload image by checking its dimensions, only if that image fits into limits it'll be uploaded to the server else we should alert the user to change the image.
The question is how to check uploaded image dimension in javascript? Thanks.
This is impossible.
What you are asking is the dimensions of a file that you've requested the user to upload.
You are talking about a file upload, ie a file that is uploaded trough the tag.
This file will only be read and uploaded to the server the moment the form is submitted. So until you actually upload the file to the server, you have no access to the contents of the file.
The browser security model prevents access to this file...
You should verify this at the server side, and display an error message if they uploaded the wrong size of file. This does mean that the file will need to be transferred and then rejected.
The only workarounds would mean to use plugins such as activeX objects or maybe flash, but then you are no longer using javascript...
I think there's no way to do this except with an URL. See this example how to do with an URL: link