Laravel 5.6 custom storage link/mount to other location on Windows OS - laravel

Laravel 5.6 custom storage link/mount to other location on Windows OS
https://laravel.com/docs/5.6/filesystem#configuration
php artisan storage:link will point the
http://localhost/storage to c:/project/storage/app/public
means visit http://localhost/storage/image.jpg = c:/project/storage/app/public/image.jpg
but how to custom the uri link to other location ? eg..
http://localhost/ramdisk/image.jpg link to z:/ramdisk/image.jpg
or
http://localhost/avatar/image.jpg link to z:/avatar/image.jpg

First of all: why would you like to do that? The images you upload should be in /storage/app/... or in /public/images/... Other disks may be unavailable if putting the app on a server.
To clarify, the php artisan storage:link only creates a symlink in /public/ folder pointing to the app/public. (I think in 5.6 it has absolute path so on server or after moving the application you have to delete and generate it again.)
So if you really want to access disk z on your PC from the app you should create a symlink in /public/ folder with the desired name. For example:
http://localhost/ramdisk/... would be a symlink named ramdisk in the public folder and would point to z:/ramdisk/. Then you would be able to access the folder contents as you wish.
Of course you can have multiple symlinks so you would create another one for the avatar folder too. Also make sure that disk z has a public access.
I was not able to test it, but I am sure that it would work, however I would not recommend it. If you want to use something in your app it should be within the app. (Except S3 drivers like amazon cloud storage.) I hope it helped.

Related

restrict access on public folder in laravel 4.2

im fairly new to laravel and im currently working on a project that needs to store files in the server. What im doing is store it under public/docs the problem is the files under that directory is accessible all the time given that they know the url to the certain file. for example even if they are logged out if they know this url http://localhost/dummy/public/uploads/docs/2016-06-02-10-52-43-oth-content-inventory-and-planning-spreadsheet.pdf they would be able to access it what im thinking is to do something like this
in my routes i would do something like
Route::any('uploads/docs/' , 'go to some controller to check if user can acces');
is this possible? thanks in advance!
it's called public for a reason...
you should use storage instead (laravel 5) in storage you dont restrict access, actualy the opposite, you grant access to the file .
try this for laravel 4.2 (move the file after upload like this to a storage folder)
Input::file('file')->move(__DIR__.'/storage/',Input::file('file')->getClientOriginalName());
});
Anyway ,the conclusion is that you can't restrict access (you shouldn't even if there is a way) because it's meant to be public ! so you should use storage folder(or whatever its called in laravel 4)

configure my web developed in local to web host

I've done some small demo of a web site and I hope to send it to a web host, but the preblem is after updating my folders and type the address, it just cannot find my web page. On local I use linux + XAMPP + Laravel so the structure is
/htdocs/laravel/public
/app
/vendor
and I just type
http://localhost/laravel/public/mywebpage
to access my web. But to use a web host who provides a file position like:
/home/sitename/public_html
do i need to create/modify any configuration file??
You can try renaming your local public folder to public_html and reflect this change at the /bootstrap/paths.php file.
There you'll find 'public' => __DIR__.'/../public', change ../public to ../public_html in this case.
I have to do something similar when I upload a laravel app to OpenShift, for example.

With GroceryCrud, how can I put uploads above application root?

I'm using GroceryCRUD to act as a front end for a database containing news releases. Secretaries can go in and add/edit/delete news releases in the database easily now. Only qualified users are able to access the application root via an .htaccess password. The problem with this is that GroceryCRUD uploads assets such as photos are uploaded to the directory /www/approot/assets/uploads/ which is password protected since /approot/ is protected.
My ideal solution would be to set an upload directory outside of the application root which is where I'm running into trouble. By default this is how GroceryCRUD handles uploads:
$this->grocery_crud->set_field_upload('photo1','assets/uploads/');
I've tried changing it to something like this:
$this->grocery_crud->set_field_upload('photo1','/public/assets/uploads/');
I was hoping this / would make the path start from the document root instead of the application root, but it throws this error:
PHP Fatal error: Uncaught exception 'Exception' with message 'It
seems that the folder "/Users/myusername/www/approot//public/assets/uploads/"
for the field name "photo1" doesn't exists.
This seems to suggest that CI or GroceryCRUD just takes the second argument in set_upload field and just concatenates it onto the end of the site URL that is defined. Is there any way around this that doesn't involve creating a user login system?
Try using relative path.
$this->grocery_crud->set_field_upload('photo1','../assets/uploads/');
.. -> Go up one directory
I ended up implementing a login system outlined in this tutorial:
http://net.tutsplus.com/tutorials/php/easy-authentication-with-codeigniter/
It was quite simple to set up and suits my needs. I found ways to give access to the directory using httpd.conf directives but I feel like this was a more viable solution since I don't have direct access to server configuration files.
Maybe in the future GroceryCRUD will allow placement of uploads outside the application folder.

Move shop to a other and new domain

i’m stuck.
I want to move a magento shop to a new domein.
Example: From testdomain.com/shop to newdomain.com/shop
I worked like this so the old shop on newdomain.com was able to keep running while building a new store on a testplace.
How can i move the shop to the newdomain.com ??
I made a sql backup from the testshop; this is a file of 15MB.
In the file there are references to testdomain.com. Offcource; i need to replace them by newdomain.com.
This replacing takes along time and mostly end ups in crashing file.
Is there another way to move a shop to a new domain ??
Thanks,
Dave
http://p1.b7d.com/magento/meghzal/
dont play with your sql file just import it as it is. if you only have 1 store view you only have to change 2 values to make you shop running.
Copy all file to you new webserver
Make the media and the var folder writeable by the webserver
Edit 'app/etc/local.xml' normally you only have to edit the database connection
With you favorite mysql tool edit the values under these paths: web/unsecure/base_url and web/secure/base_url set them to your new domain like http://newdomain.com/. if you have an ssl certificate use https for the secured one if not use normal http.
Now very important clear the cache. normally the cache is under var/cache but in case this one is not writable magento switches to the tmp folder of you server. So check you tmp folder for something like /tmp/magento and remove it
If you need to COPY installation of Magento to another server use the manual by Fantus here. Beware of different php.ini configuration, and OS (from Win to Unix set correct the rights by chmod)
If you have the same installation and ONLY CHANGING ENTRANCE DOMAIN to the same installation of Magento:
configure your domain A record to IP adress of your server
configure a vitual host of your ewb server (apache or etc) to reverse domain to magento folder
change configuration of new domain in magento/app/local.xml
Clear the magento/var/ folder (not neesesary)

Codeigniter App on EC2 - Helpers not loading

I recently just started to migrate over a CI application to Amazon's EC2 service. To test I set up a micro instance of ubuntu and a LAMP stack. PHP, MySQL, HTTPD are all working beautifully. The one issue i'm having now is that when I run my application I receive an error saying that my helpers won't load. The helpers in particular that aren't loading are the ones in subdirectories in the helpers directory ie: /var/www/system/application/helpers/subdirectory/foo_helper.php
The helpers are being autoloaded and in my autoload.php config file they are written like:
$autoload['helper'] = array('subdirectory/foo', 'foo2',...);
Has anyone run into this issue, or have any pointers on where I could go look in my configuration to resolve this?
Thanks for the help!
I'd try debugging the helper function of the Loader class, in particular these lines :
system/libraries/Loader.php
elseif (file_exists(APPPATH.'helpers/'.$helper.EXT))
{
include_once(APPPATH.'helpers/'.$helper.EXT);
}
This is the code that will be hit when including application helpers. Check what path CodeIgniter is trying to include. Double check that the path exists - everyone makes typos now and again ;-)
I think the issue is that when I moved from Windows to Linux I forgot to take into account that linux is case-sensitive. So now I need to go through and rename my files and folders.
But this still doesn't solve the issue where it seems like the page is being cached and I'm not able to refresh and see my changes. Is there any way to force the page to grab a fresh copy from the server on every refresh?

Resources