CkFinder - Images from different folder mixed up - ckeditor

I have different folders under CKFinder to store images of different users.
I can also browser them separately without disturbing images of other users.
The problem occurs when two users have images with the same name say "1.png", then one image is shown for both users.
If we have 2.png for userA and 3.png for userB then there is no problem of images mixed up.
In SetConfig function of config.ascx
string folderPhysicalPath = Server.MapPath("~/Uploads/Images/"+MySession.ClientKey);
if (!System.IO.Directory.Exists(folderPhysicalPath))
System.IO.Directory.CreateDirectory(folderPhysicalPath);
// The base URL used to reach files in CKFinder through the browser.
BaseUrl = Convert.ToString(ConfigurationManager.AppSettings["AppPath"]) + "/Uploads/Images/"+MySession.ClientKey+"/";
// The phisical directory in the server where the file will end up. If blank, CKFinder attempts to resolve BaseUrl.
BaseDir = folderPhysicalPath;
.
.
.
.
type = ResourceType.Add("Images");
type.Url = BaseUrl + "/Images/";
type.Dir = BaseDir == "" ? "" : BaseDir + "/Images/";
type.MaxSize = 0;
type.AllowedExtensions = new string[] { "bmp", "gif", "jpeg", "jpg", "png" };
type.DeniedExtensions = new string[] { };

I have changed resourcetype to be dynamic instead of static "Images".
type = ResourceType.Add(MySession.ClientKey + "_Images");
This solved my problem..

Related

how to use database saved links of image to get images from laravel folder

i have saved images in 'public/images' folder in Laravel and the link/name is saved in mysql database. all i want to get all images via api call. the problem is i can get a single image easily but couldnt get all the images.[[[enter image description here](https://i.stack.imgur.com/9gerk.jpg)](https://i.stack.imgur.com/MIBIk.jpg)](https://i.stack.imgur.com/QcPQm.jpg)
i have no issue with single image however unable to get all at once. thanks
Try this instead
Store the only image name and extension into database and then retrieve it by using DB and use asset to get image, refer the following code as practice.
$custom_data = array();
for ($i = 0; i <= $total_images; $i++) {
$image_name = $data[$i]->image;
if ($image_name != "") {
$image_with_path = asset('public/products/') . '/' . $image_name;
} else {
$image_with_path = "";
}
$custom_data['image'] = $image_with_path;
}

Why is the toolbar not visible in executable Jar created using IntelliJ?

I have created a jar file for my GUI application using IntelliJ. However, when I run the file, I cannot see the toolbar which contains the buttons with ImageIcon for different functionaltites. On looking around over stackoverflow (like here: Java Swing ImageIcon, where to put images?), I found that the file path for the images could be an issue. At present I am using the following code:
OpenImagingFileButton = new JButton(createImageIcon(currentPath.concat("/src/main/java/uni/images/open-file-icon-img.png")));
The currentPath variable is obtained using this:
final String currentPath = currentRelativePath.toAbsolutePath().toString();
And the createImageIcon method has the following code:
/**
* Returns an ImageIcon, or null if the path was invalid.
*/
protected static ImageIcon createImageIcon(String path) {
ImageIcon toolBarImage = new ImageIcon(path);
Image image = toolBarImage.getImage(); // transform it
Image newImg = image.getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH); // scale it the smooth way
toolBarImage = new ImageIcon(newImg); // transform it back
return toolBarImage;
}
This code works perfectly when I run it in intelliJ, however, the toolbar is not visible when I run the jar. I also tried moving the images folder directly under src folder and then doing this:
ImageIcon(this.getClass().getResource("/images/open-file-icon-img.png"));
But this gives me aNullPointerException. Where am I going wrong?
You don’t need to use the current path here. Since you are working in IntelliJ, simply mark the folder as resources root, by selecting the src folder and right clicking it to find
mark directory as
Move the images folder under the src folder. Then use the following code to set the image icon as a button
Java - setting classpath
openProject = new JButton();
openProject.setIcon(createToolIcon("/images/openProject.png"));
And place the createToolIcon method in the same class file or create a separate class and call the method using that class.
public static ImageIcon createToolIcon(String path) {
URL url = System.class.getResource(path);
if(url == null) {
System.err.println("Unable to load Image: " + path);
}
ImageIcon icon = new ImageIcon(url);
Image img = icon.getImage();
Image newimg = img.getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)
ImageIcon newIcon = new ImageIcon(newimg);
return newIcon;
}

Laravel - copy image

i need to copy an image and save in diferent name. how can i do this in laravel?
Please help me.
img/master.jpg -> copy -> paste with different name (user1)
----now------
img/master.jpg
img/user1.jpg
You can use laravel File helper, here is the file System Doc.
$oldPath = 'images/1.jpg'; // publc/images/1.jpg
$newPath = 'images/2.jpg'; // publc/images/2.jpg
if (\File::copy($oldPath , $newPath)) {
dd("success");
}
if you need to rename it following would be helpful,
$oldPath = 'images/1.jpg'; // publc/images/1.jpg
$fileExtension = \File::extension($oldPath);
$newName = 'new file.'.$fileExtension;
$newPathWithName = 'images/'.$newName;
if (\File::copy($oldPath , $newPathWithName)) {
dd("success");
}

Save and read files in isolated storage

I try to save files in IsoStore. In WP8 emulator files have been successfully saved, but when I run my program in other emulators or on my phone(with WP7.8) I get a error: "path must be a valid file name"
I do this:
var path = #"\Shared\Media\mapp\";
var imageName = guid from the server;
if (!_fileStorage.DirectoryExists(path))
_fileStorage.CreateDirectory(path);
//here I get a error using (IsolatedStorageFileStream fileStream =
_fileStorage.OpenFile(path + imageName,
FileMode.OpenOrCreate))
{//do anything}
I try to set path = #"iso:\Shared\Media\mapp\" or #"isostore:\Shared\Media\mapp\" or #"files:\Shared\Media\mapp\" or #"file:\Shared\Media\mapp\" and it doesn't work.
If I set #"\Shared\Media\" all fine in all devices. Who can tell me why I can't create a directory?
For Windows-Phone-7 you can't create a directory, which name ends with "/" or "//", that will cause an "path must be a valid file name" error.
To solve your problem, just change your code a bit:
var path = #"\Shared\Media\mapp";
var imageName = guid from the server;
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!store.FileExists(path))
{
store.CreateDirectory(path);
}
store.OpenFile(path + "\\" + imageName, FileMode.OpenOrCreate);
}
Hope, that helps.

mvc3 ImageResizer

I downloaded the Nugent ImageResizer and I am trying to resize a picture on upload following an example on this page http://imageresizing.net/docs/managed but I can't seen to put this in a Var or Image variable so i can see it in the Path.Combine here is the code
var fileName = Path.GetFileName(file.FileName);
var changename = getid + "_" + fileName;
ImageBuilder.Current.Build(changename, changename,
new ResizeSettings("width=130&height=130"));
var path = Path.Combine(Server.MapPath("~/uploads/profilepic"), changename);
file.SaveAs(path);
How can I get the ImageBuilder inside a var or some type of image variable what i would like to do is something like this
var resized= ImageBuilder.Current.Build(changename, changename,
new ResizeSettings("width=130&height=130"));
var path = Path.Combine(Server.MapPath("~/uploads/profilepic"), resized);
file.SaveAs(path);
all that im trying to do is put the ImageBuilder inside the Path.Combine without getting an error, any help would be appreciated .
ImageResizer should be given the uploaded file and the output path directly
ImageResizer supports both GUIDs and path sanitization. NEVER use the uploaded filename as-is!
var i = new ImageJob(file,
"~/uploads/profilepic/<guid>_<filename:A-Za-z0-9>.<ext>",
new ResizeSettings("width=130&height=130&format=jpg"));
i.CreateParentDirectory = true; //Auto-create the uploads directory.
i.Build();
var newVirtualPath = ImageResizer.Util.PathUtils.GuessVirtualPath(i.FinalPath);

Resources