How to make the browser upload and display image after the user puts it in the file upload widget? I've got a form where an image should be uploaded and edited by the user on the fly (before they hit submit). Can I do it with Jquery?
Take a look at the JQuery MultiFileUpload plugin.
MultiFileUpload plugin should give you what you're looking for. It's important to remember that ajax does not support transferring binary files - you'll need an embedded IFrame to do the work for you.
Related
I was looking at this question Download image with JavaScript which shows how to download an image.
I want to be able to do something similar but more automated. I would like to navigate to an imgur page, enter some search parameters then use jQuery to download any .jpeg or .png
I have the basic layout
navigate to imgur and search
find all .jpeg and .png in page
run code similar to other question to download
What I want to know, is can I specify a specific folder to save the images to?
Can I automate the click of the Save button?
If this is not possible in pure jQuery/javascript my other choice is to default to using iMacros with some javascript mixed in, I would however like to avoid this.
This is not possible using only JavaScript.
A user's interaction will always be required in order to save a file. Imagine the mess we'd be in if that weren't the case... Viruses everywhere!
I have a QR Code and an Image in a div. I want to copy the QR Code and the Image by clicking a Copy button and then paste them to word file.
Is this possible using jQuery/JavaScript?
Not possible. File operations can not be done in JS/Jquery side and its not allowed by browsers(thank god!). Activex can make it possible but I don't think you want that. There the File API of HTML5 but not all browsers support.
My Suggestion would be to create WebMethod/WebService to do something like this, make ajax call to this webservice from your javascript or Jquery. User experience will remain same as you intend.
I am using sitecore and all images are converted to .ashx handler. I currently added a script to share images on google, facebook, twitter. When someone selects the share button for example on facebook, it longer embeds the png image because it doesnt recognize .ashx as an image. Is there something I can add to my script to handle this?
Thanks.
Brendan,
You will need to set the "Media.RequestExtension" setting, I generally create a SitecoreSettings.config file under the /App_Config/Includes/Custom folder to house my seetings. Out of the box Sitecore uses the ASHX extention for all items stored in the Media Library.
<setting name="Media.RequestExtension">
<patch:attribute name="value"></patch:attribute>
</setting>
More information about Media URL can be found from this John West article: http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/12/Sitecore-Idiosyncrasies-Media-URLs.aspx.
Hope this helps.
Chirag
Hey guys I have searched a lot but didnt get any working solution for this problem.
I am working on a site using jsp and on this we have to upload forms in doc / docx/ pdf format. I want to generate the preview of the first page of the form. So that user can checkout whats in the form before downloading it.
Hope someone will come up with some solution for this.
Thanks
Not sure what OS platform you are on for your jsp, but my recommendation would be to have a virtual printer driver that can "print" the document at hand to an image file (or as HTML). Then you can manipulate the output of the printer driver anyway you want. Extends itself nicely to other file formats as well.
Another version of this technique would be to programatically open the document with Microsoft Word (using ole automation), then do a screen capture after the document opens. Word can load PDF files as well. You'll have to find a creative way to get the document into a Windows desktop process from your server. But it could work.
Well.. what you can do is..
Hyperlink the form names with relative paths of your jsp with download option. You need to write a servlet to download the form.. preview this jsp in pop up window.
or
use iframes in html create a div tag to preview and download the same form you are displaying. You need to write a servlet to download the form.
Make sure you set the appropriate contentType of your forms doc/pdf/jsp using response.contentType("image/jpg");
response.contentType("application/pdf");
response.contentType("application/doc");
I want to get an icon's image when a user drags and drops it over some kind of div, but that it'll show exactly what the user sees (e.g. thumbnail, *.ico), is it possible to do so, or does anyone know of any projects that do similar things?
I would suggest a mix of:
This great drag and drop upload library:
http://valums.com/ajax-upload/
This javascript code to preview uploaded images before they upload
How to upload preview image before upload through JavaScript
You would have to add a listener in Valum's uploader to get the file that is being uploaded and then display it using the code in the second link.
Getting the local image path via javascript is not an easy task... and being able to do that while supporting most browsers will be even worst...
An easier way to solve your problem would be to upload the image in a temporary location on your server, return that temporary path and display the image that was just uploaded. Then you add a second "Keep" and a "Discard" button that saves the uploaded image to a real path if the user likes what he uploaded and you delete the temporary image. Since your images are .ico, I assume they are not really big files, so they would upload pretty fast and the user would get a "preview" fast too using that technique.
You should ask yourself if all the time invested on tweaking your code to show the user a preview before the upload really improves the user's experience using your tool !
You may need some extra work for converting ico files to file formats viewable in browsers (e.g., JPEG, PNG.)
Drag and drop the images to the browser is possible if you use HTML5's Drag and Drop API. (https://developer.mozilla.org/en/DragDrop/Drag_and_Drop, http://www.thebuzzmedia.com/html5-drag-and-drop-and-file-api-tutorial/).
After capturing the user input, you can upload the images to your server. After that you can convert the images whatever you want them to be. Finally you can show the images to the users.
Here is a great tutorial that I think can help you with many problems. If I understood your problem right.
http://www.elated.com/articles/drag-and-drop-with-jquery-your-essential-guide/
I don't know if you want to use html5, but I think that with jQuery you can do that. I've found this url: http://decafbad.com/2009/07/drag-and-drop/api-demos.html#data_transfer
Here you've a "Using drag feedback images", maybe this can help to you :)