How to set the default location of the FCKEditor file browser? - php

I'm working the the image upload piece of the FCKEditor and I've got the uploading working properly but am stuck with the server file browser.
You can see in the dialog above has a Browse Server button which pops up the following dialog
The problem is that I have no idea which folder the file browser is pointing at.
I've set the UserFilePath and USerFilesAbsolutePath in the PHP connector config.php to control where my image uploads go.
How can I configure the file browser so that it starts off pointing at the same folder where my uploads are going?
Edit
The ImageBrowserURL property is NOT what I'm looking for. That property is used for having the Browser Server button point somewhere other than the default file browser.
My problem is figuring out how to point the default file browser to a specific directory.

Please read this post of mine on FCKeditor forums. Are you having the same problem I had?

Is it this?
ImageBrowserURL
(string) Sets the URL of the page called when the user clicks the "Browse Server" button in the "Image" dialog window.
In this way, you can create your custom Image Browser that is well integrated with your system.
See http://www.clinicaestet.ro/FCKeditor/_docs/contents/012.html

You need to set some config information for the FCKEditor. This is done either in javascript code in your webpage or you can do it in the FCKEditor config file which is located typically in /fckeditor/fckconfig.js file. If you did not install the fckeditor to the typical fckeditor directory, you will need to replace that part of the path with the correct path.
In the fckconfig.js file you need to change the "ImageBrowserURL" setting to whatever you want.
FCKConfig.ImageBrowserURL = '/myfilebrowserpath/browser.php' ;
This is where the dialog will look for your files. Here is a link to FCKEditor documentation on this. I hope that helps.

Related

Get Path of File in PHP without Uploading

So essentially I want to insert the Path into my Database, as a string, I am not interested in uploading it - I just want local users to browse to the file then submit the form and the path to the file is added as a string. So when I echo this out into a url, people on the network can click the link to download it from the network location.
$location = fopen($_FILES["location"]["tmp_name"], 'r');
I've tried the above but I guess the file needs to be uploaded for it to get the path.
Any ideas?
Unfortunately PHP will not help you with this as it requires you to actually upload the file.
Likewise, as was mentioned in the comment you are not able to get the local file path either from the form. This is a browser standard and is done for security purposes. You can read more about it here: https://stackoverflow.com/a/4176605/8518859
The only solution in your case is to provide a text input and ask the user to paste the network path to the file. Perhaps if you provide them simple instructions on how to get the network path it will make their task easier.

What are possible reasons that HTML download link is failing?

I created a page for users to download certain files. I used the HTML download link to do this as so:
<a download href="/home/Uploads/someDir/someFile.PNG" >View</a>
This worked fine when I was developing on my laptop with WAMP. When I uploaded the code to our Centos 7 Server it did not work. I changed the Uploads, someDir, and someFile.PNG permissions to 777. I also made sure that the file path was correct. But the when the download link is pressed the file icon at the bottom of the screen says "Failed no file".
Maybe I need to do more with the permissions. I know that the folder that the html file is in has restricted permissions, but I would prefer to keep them that way. I do not know how that could cause an issue.
I am looking for debugging tips/possible causes. At this point I am clueless where to look.
The issue with the download not working is simply due to the fact that the path to your file is wrong. My advice on your root directory which is in most cases is var/www/html, create a folder called say somefoldername and manually upload the file to that folder then change the download link to be
View.
"Failed no file" has nothing to do with permissions. The path to your download file has most likely changed when the files were uploaded to the server. You should manually check to see if the file at
/home/Uploads/someDir/someFile.PNG
actually exists. If not you can change the link accordingly or move the download file to the appropriate location.
Another good alternative to solve this error is to put a dot '.' at the beginning of the url:
<a download href="./someDir/someFile.PNG" >View</a>
This way you will not need to indicate the complete url.
And if in the future the url changes, you won't have to modify the url.
In my case it works perfect, I hope it helps you too.
Just check the directory in which you are trying to fetch the file. Your looking file may be not present in that directory. Otherwise, you are using the correct piece of code.
<a download href="~/home/Uploads/someDir/someFile.PNG" >View</a>

Copying Facebook Profile Picture Creates a 0kb Image File

This used to work and now it doesn't on my server. This is kind of a last ditch effort to try to figure out what is going wrong here. I'm simply trying to copy a profile image from Facebook to a folder on my server. Here's the only code I'm using:
file_put_contents("..//images/artist_pictures/artist_216.jpg", file_get_contents("http://graph.facebook.com/553451657/picture?type=large"));
After that runs I get a 0kb image file called artist_216.jpg. Any ideas?
I'm not too good with PHP, but I know that the picture URL you're using is a redirect to another file on Facebook's CDN. I'm guessing you need to somehow resolve the actual location and pull the contents of the redirect.
You need to adjust your php.ini file.
Change allow_url_fopen = Off to allow_url_fopen = on.

How to let a user open a file stored on the server?

I have a WordPress site, in which type1 users can upload *.doc files and type2 users should be able to open them by clicking on a link which represents a file.
The file then should be opened in a new window of the browser.
I got the first part easily - there are many guides on uploading a file.
But I couldn't find one that goes through all the steps of getting and opening a file which resides on a server directory.
I assume clicking the link should cause an ajax request which will send the file key to the server.
The server can then get from the MySQL DB the file name and location.
But what do I do then?
How do I get the file from the server directory, send it back to the client and open it for reading in the browser?
Edit:
I want the files to be confidential and not let just anyone read them so giving the users the link for the file on the server isn't the right way.
I still think I need to send the file from the server directory to the client.
How can this be done?
You can add links to uploaded media in WordPress easily. Just remember to link to the actual file:
I want the files to be confidential and not let just anyone read them so giving the users the link for the file on the server isn't the right way.
Yes it is. You can't let people read the document without giving them the document.
If you want to keep it confidential, then require the users to agree not to share the link with anyone else. Or go further and add a layer of authentication + authorisation and also require that users not hand over their credentials.
Simply, redirect the browser to the location of the file. It's depend on user's browser settings that file opens on the browser directly, or user sees open/save dialog.
But, if you want to open the file inside the browser without letting user download it, you should redirect her/him to a custom page. e.g. a page that loads a doc editor.
There's no way to show a Microsoft Word file inside the browser unless they install proper software. e.g. an Applet or ActiveX or something that be able to open MSWord files.
Consider using WP Client File Share plugin.

Server doesn't show file replacement until I open it in my file explorer

So I am running xampp and wordpress. I have an image uploaded to the uploads directory named "avatar.jpeg". It displays just fine. But when I delete it and upload a new image file named "avatar.jpeg", the server doesn't reflect the change and just shows the old file. But when I open the file in Eclipse or my explorer, then the server starts showing the change and displays the new image.
This is probably something basic which I never learned about. I tried chmod to set the file permissions on the new file but that didn't help.
The file will be cached in your browser. To force a reload, append an arbitrary variable to your file, e.g. <img src="yourfile.jpg?1234567" />
I also guess it's a caching issue like freddy K. does.
I would suggest to configure ETags on your Server.
Simply appending something to the URL may only help you when the appended string is changing on every update of the requested file(using the current timestamp or similar all the time will force the client to download the file on every request and slow down the page).
http://httpd.apache.org/docs/2.0/mod/core.html#fileetag

Categories