I have an asp.net 2010 project. I write a jpg to the filesystem. Then I display it in an Image control. Then I use this code on button click to allow the user to rotate it 90 degrees.
string path = Server.MapPath(Image1.ImageUrl) ;
// creating image from the image url
System.Drawing.Image i = System.Drawing.Image.FromFile(path);
// rotate Image 90' Degree
i.RotateFlip(RotateFlipType.Rotate90FlipXY);
// save it to its actual path
i.Save(path);
// release Image File
i.Dispose();
It does rotate (I can actually watch that happen in Windows Explorer). But when I run the app again and it grabs the file from its path, it still displays it in its original form.
Try adding a dummy querystring to the end of the image like "image1.jpv?v=1". This works to prevent caching for things like Javascript files and it may do the same for you.
This is the classic issue with browser-cached resource files. Alison's answer is one option. Another option is to change the name of the physical file. If you "version" the files, then after each change, the file name will be different. This does mean that you'll have to dynamically reference the image path so that you display the correct version, and you'll need some way to determine the file name for the current version. It does prevent the browser from displaying the previously cached file immediately after a change, though, because it's technically a new file to the browser at that point.
If you are using some sort of data source (XML files or database) to store metadata for the images, then you can add a "Version" column and store a simple integer. With each change, increment the integer value and use the new value in the file name. You can even extend this by saving the previous versions and allowing your users to "undo" actions by copying an older version of the file into a new version. This might require a more robust metadata storage implementation, though.
Related
The new TinyMCE 4.3 Image Tools (eg when cropping) saves images as blob data instead of image files in a directory. the edited mage url is like
blob:http://www.example.com/f2953aa1-e64f-49e1-a6e3-a283986663bf
I want to upload the image file to a specific folder and then use it as regular image referance / path.
Note
The question I am going to put is similar to Image edit issue. but the answer to this question is not working. I also tried http://archive.tinymce.com/forum/viewtopic.php?id=35740 solution but not working because it produces always same name image name.
The basic process is that TinyMCE will create a separate HTTP POST for each image that you modify with the image editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.
The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:
Store the item in a folder on your web server
Store the item in a database
Store the item in an asset management system
...regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:
{ location : '/uploaded/image/path/image.png' }
TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location. The TinyMCE page has more details on all of this:
https://www.tinymce.com/docs/advanced/handle-async-image-uploads/
The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.
I have an OleCustomControl which displays the contents (documents &/or folders) of the path I specify.
I'm able to zoom in/zoom out (increase/decrease) which resizes the icons of documents &/or folders. For ex: I have set it to Extra Large Icons.
Once I close the application & re- run it, I want to be able to view it in the same way I set it last time i.e. Extra Large Icons.
Is there a way by which I can access this setting in power builder code?
If there would be one, I'll maintain the status & then set it back.
Since you didn't tell us the name of the control, we can't help you with specifics. Check the vendor website for documentation.
If you named the control ole_1, it should be something like this:
ole_1.object.thepropertyname = "thevalue"
or
ole_1.object.themethodname("thevalue")
I finally found the answer.
I can use the IconSize property to store the current icon sizes. I store this value & reset it when user opens the application again.
Ex: oleControl.Object.Document.IconSize
How I found this?
It should have been simple as the property name says it. However, I found it from the registry settings, where there is a registry entry for IconSize.
I've got an interactive presentation, and it's all working as it should.
Now I want to add a function to download the currently visible image/video.
Because this presentation has a lot of files (all stored under assets/...) and it's a pain to navigate through the assets, I want an easy way to just click a button and get a "Save as.." window.
I've managed to get the url of the media, so now I just need a way to show a "save as.." dialog to allow the users to save/download the file and save it locally.
This whole presentation should be put online, so all the files are located somewhere in the /assets/.. folder inside the project.
Any ideas of how to do this? =)
Thanks!
EDIT #1:
For now I'm using "navigateToURL" to open a new browser window with the media. This works, but is there a way to show a "Save as.." dialog instead of opening the image?
Or any other ways to do this? =)
You are looking for the FileReference class, in particular the FileReference.save( data:*,defaultFileName:String = null ) method. That will open up a "Save..." dialog to save the corresponding data object and allow you to set a default file name. I'm unsure if this class can also handle the download as I have never had a time when I needed to prompt to save something that was to be downloaded. If it cannot handle it, you'll need to look into the URLStream class. That can handle the download and either on ProgressEvent.PROGRESS or Event.COMPLETE, you simply do a URLStream.readBytes( byteArray ); to save the downloaded bytes to a ByteArray and then that is the data object you save. I would look into the FileReference class, though. Odds are it can handle downloads as well.
I'm attempting to modify an inherited project that has a convoluted process of displaying uploaded images using an ImageMap control.
The current process inserts a new database record with image file name as well as model number and part number. The image files are saved to a virtual directory visible to IIS. Each part number has a corresponding .htm file containing an image map referencing the uploaded image. The image map has to be sized for each part and saved in the file system.
How can I streamline this process using either client side or server side controls? I'd like to bypass use of image maps as they require manual sizing. Can a control be used that auto sizes the image? Should the images be stored inside the database or kept in the file system?
Thanks for your advice;)
Storing the images in the database is IMHO a much more scalable solution.
Take a look at the Image Resizer project and its associated plugins for a way to resize the images, regardless of where you store them:
http://imageresizing.net/
http://weblogs.asp.net/bleroy/archive/2011/10/22/state-of-net-image-resizing-how-does-imageresizer-do.aspx
http://nathanaeljones.com/163/20-image-resizing-pitfalls/
You could use regular ASP.NET controls to display the images, for example, a ListView.
I need user download JPEG file from my app, however, when user change the file name the saved file will be downloaded without extension.
For Example: I am using FileReference.download() and set the default filename as "demoPic.jpg" and user's windows system setting control file extension not being shown. So when the dialog opens a download window, only "demoPic" shown as the filename. If user saved file without changing filename, the saved file will be OK. But if user change file name, the download file will be saved without extension. is it possible to add file extension to filename when user forget it by flex code?
This is a known problem with Flash Player. An enhancement request is filed with Adobe. Please visit and vote for it: https://bugs.adobe.com/jira/browse/FP-2014
It does not seem practical to train users not to rename the file. Here is the workaround I use for my app:
The problem only happens on Windows with ActiveX plugin. Detect ActiveX with Capabilities.playerType (only ~25% of users in my experience)
If ActiveX plugin, fall back to 'navigateToURL()' to bounce the file on your server. Using this function is less desirable than FileReference.download() because it is less controllable (the browser is in charge, rather than your app), but it results in a Save dialog box where the user can rename the file safely.
I have the same problem and was not able to fix it until now. It seems it is a problem with flash + windows. :( sorry to inform but I did not found any fix.
If this can be called a workaround, is somehow to warn users and ask them to place also the extension when they rename the file.
Had same problem. Used CONCAT to manually add extension. It does not appear in the dialog box when saving but DOES save as a text file with a .txt extension when viewed in Windows Explorer. Doesn't seem to work but actually does!
var final_filename:String = filename.concat(".txt");
//Create text to save from text field
var newDataFile:TextField = new TextField();
newDataFile.text=myTextField.text;
//create file reference to save file
var file:FileReference = new FileReference();
file.save(newDataFile.text, final_filename);
you just need to use navigateToUrl(ur)
var ur:URLRequest=new URLRequest();
var fr:FileReference=new FileReference();
fr.download(ur,<FILENAME>);
"download" method call fileBrowser and then call servlet .
then flex can't catch file extension
but "navigateToUrl" called servlet first then servlet call fileBrowser
then html can catch file extension