I am trying to clean up project structure by moving 'Page' directory form root location to some internal folder's like client or frontend etc. Is there way to do it? and can I move css and images folder as well?
As far as the pages directory is concerned, it's not configurable yet but it has been discussed so the feature might be available some time in the future: https://github.com/zeit/next.js/pull/936
Images are usually best kept in the static folder, eg. /static/img/favicon.png, if you move your images somewhere you'll lose Next.js feature of automatically setting up static files serving under /static/*.
Regarding CSS however, you're free to move these files under any folder you want because you have to import them in your code yourself: https://github.com/zeit/next-plugins/tree/master/packages/next-css
I'm trying to retrieve a picture from my file system after a good storage,(instead of putting it in the database I copy it to the disc and i put the path to the db)
I had store the picture to c:\images\ folder and supposing that the name the complete path is c:\images\mypic.jpg
when I try to retrieve it a set the img src attribute to <img src="c:\images\mypic.jps"> by using some java code
in the browser console I found this error Not allowed to load local resource: file:///C://images//mypic.jpg
Question: how to fix these path problem ? where Should I store the pictures ? and from where should I retrieve them ?
sending tag <img src="c:\images\mypic.jpg"> would cause user browser to access image from his filesystem.
if you have to store images in folder located in c:\images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.
But what you use to create your application? is it pure servlet? Spring? JSF?
Here you can find some info about, how to do it.
In Chrome, you are supposed to be able to allow this capability with a runtime flag --allow-file-access-from-files
However, it looks like there is a problem with current versions of Chrome (37, 38) where this doesn't work unless you also pass the runtime flag --disable-web-security
That's an unacceptable solution, except perhaps as a short-term workaround, but it has been identified as an issue:
https://code.google.com/p/chromium/issues/detail?id=379206
You have Two alternatives :
First one is to create a ServletImageLoader that would take as a parameter an identifier of your image (the path of the image or a hash) that you will use inside the Servlet to handle your image, and it will print to the response stream the loaded image from the server.
Second one is to create a folder inside your application's ROOT folder and just save the relative path to your images.
Many browsers have changed their security policies to no longer allow reading data directly from file shares or even local resources. You need to either place the files somewhere that your tomcat instance can serve them up and put a "regular" http url in the html you generate. This can be accomplished by either providing a servlet which reads and provides the file putting the file into a directory where tomcat will serve it up as "static" content.
The concept of http location and disk location is different. What you need to do is:
for uploaded file summer.jpg
move that under a known (to the application) location to disk, e.g c:\images\summer.jpg
insert into db record representing the image with text summer.jpg
to display it use plain <img src="images/summer.jpg" />
you need something (e.g apache) that will serve c:\images\ under your application's /images. If you cannot do this then in step #2 you need to save somewhere under your web root, e.g c:\my-applications\demo-app\build\images
This error means you can not directly load data from file system because there are security issues behind this. The only solution that I know is create a web service to serve load files.
Here is a simple expressjs solution if you just want to run this app locally and security is not a concern:
On your server.js or app.js file, add the following:
app.use('/local-files', express.static('/'));
That will serve your ENTIRE root directory under /local-files. Needless to say this is a really bad idea if you're planning to deploy this app anywhere other than your local machine.
Now, you can simply do:
<img src="/local-files/images/mypic.jps"/>
note: I'm running macOS. If you're using Windows you may have to search and remove 'C:\' from the path string
Do not use ABSOLUTE PATH to refer to the name of the image for example: C:/xamp/www/Archivos/images/templatemo_image_02_opt_20160401-1244.jpg. You must use the reference to its location within webserver. For example using ../../Archivos/images/templatemo_image_02_opt_20160401-1244.jpg depending on where your process is running.
I created a sub domain named test on http://www.t2transfer.com/ and I put a index file. When I go to http://www.t2transfer.com/test/ url It shows a 404 page and blue host webpage. I also tried by creating a folder names test. But It also shows same result. Why is that? Please guide me to solve this.
You are accessing a folder path, a sub-domain would look like http://test.t2transfer.com/
I have a site in cakephp,the issue I am having is the images and css files are pointing to bedutech.com/
while cakephp structure the images are in the img folder that is located in : app/webroot/img
same goes for the css file so I cant see the site layout properly.
any suggestions ?
You first need to find out where the bedutech.com is pointing to and whether it's pointing to the server that has your Cakephp site stored. If so, Cakephp has a routing structure so that anything under webroot folder is accessible as a root in URL. This means you can type bedutech.com/img or bedutech.com/css to access webroot/img and webroot/css folders.
If you have trouble finding out whether bedutech.com is actually pointing to your Cakephp server, you can either check DNS records by going to who.is/bedutech.com or actually test it out by typing in the URL in your browser.
My CakePHP Folder Structure
1. app / webroot / img
2. cake
3. vendors
4. assets
<?php echo $html->image('cake_logo.png', array('alt' => 'CakePHP'))?>
Is it possible to access my external asset directory with the CakePHP Image helper?
I've never tried this, but I believe that Cake relies on the web server to serve up image assets by default. This would suggest that, no, you can't move your images outside of your web root and still use the HTML helper's image() method.
You can, however, use media views to send binary information to users. It works outside of the core helpers, but might meet your needs.
Try to go up the directory by adding ../ at the front of image file as many times as it is necessary like this:
echo $html->image('../../special_assets_folder/cake_logo.png');
That worked for me in some cases.