Access Laravel stored files from android app (ionic). - json

I'm working on an android app with Ionic 3 connected with Laravel to control my data through an api, and i'm trying to display a bunch of images on my ionic app, the problem is i can't.
I was trying to access laravel's storage folder but i can't, i don't know if it's possible to convert a blob image to json ...
Any ideas ? Thanks !

By default, laravel's storage folder can't be seen to the public web.
When you access your laravel app, you are actually accessing the 'public' folder of the root structure. Therefore, only the application has access to the storage folder.
Run the following in your command line in root folder
php artisan storage:link
This will create a symbolic link from public/storage to app/storage/public.
Now, you'll have to put your images inside the app/storage/public folder, and access them trough http://[yoursitehere].com/storage/image1.png

Looks like you need to link your storage directory to your public folder so it's accessible.
Link the storage folder:
php artisan storage:link
Get the image URL:
echo asset('storage/image.jpg');
Check the documentation here https://laravel.com/docs/5.5/filesystem#configuration

Related

How can I disable direct access to a folder html page?

Heres the scenario: In the root of the server i have an folder named "data".
In this folder is a file named "random-file.html". Now I want, that you can't see the contents of the folder "data" if you type "domain.com/data/" but you have access to the file "random-file.html" and can it.
Sure you can. You can hide it using .htaccess. I assume you use xampp server. You can see this [1] https://www.opentechguides.com/how-to/article/apache/115/htaccess-file-dir-security.html
If I recall correctly, the most secure practice is to keep sensitive files outside the root of your webserver all together. Create a folder on the VM or server which your app is hosted and have your application read/write/use it from there.
Most serverside frameworks/tools have a "websecrets" type functionality you could use. But this step above is my 'framework agnostic' advice.

Save Images in advanced application of yii2

i have a field called photo in model members. I want to access the photo
from both frontend and backend. So i created two folder called images in backend\web\uploads and frontend\web\uploads and my idea is to save the photo in both backend and frontend at the same time.
If i have to save an image in frontend\backend i would have used this code
if($model->photo != null)
{
$model->photo->saveAs(\Yii::$app->basePath . '/web/uploads/photo/'.$model->id."_".$model->photo);
}
but i can't use this code for my purpose because i have to save it in both frontend and backend. How can i do this?
you can make a symbolyc links so you don't have to save the file in both directories.
in linux just run ln command from a console, example you have backend\web\uploads directory and then you make frontend\web\uploads as a symbolic link to backend directory.
in linux just run:
ln -s backend/web/uploads frontend/web/uploads
in windows, open command promt, go to your yii2 directory and run:
mklink /D frontend\web\uploads backend\web\uploads
notice that mklink inputs is in reverse order than the ln command in linux
In ideal you should create static subdomain like static.yourdomain.com and save images to only one place.
In your case you should duplicate save code to frontend and backend folders.
For example:
You can have the uploads folder inside the common folder. Your save code should now reference the folder:
$model->photo->saveAs('#common/uploads/photo/'.$model->id."_".$model->photo);
You can then save the base image url in your application's param configuration and use that in your views.

loading html page into rails server

I created the whole responsive site in notepad - shop.html. I
can see its directory in rails. Put all my files in public folder of its rails app. Now I dont know how to load it in localhost:3000. How do i do that. Have configured everything. Rails server is running and It shows only the default index.html file. But when i write rails generate controller eshop. It says uninitialized constant welcome error.
PS: i m new to ruby.
All guides show how to create a new app but I couldnt find a way to load a html page already created in editor to load in browser using rails server.
Thanks in advance.
Since you generated a controller you need to put the content from your shop.html file into the /views/eshop/index.html.erb file
Open the routes file under config/routes.rb and change the following line
from:
root "welcome#index"
to:
root "eshop#index"
this way your app will point to the right file.
Subsequently you could just point the root to the shop.html file which I do not recommend. However you should definitely look into routing in rails and how it works.

Laravel-4 and phpmyadmin installation in fortrabbit

I would like to know how to install phpmyadmin along with Laravel-4 project in fortrabbit..The problem is that if the phpmyadmin folder is in the laravel's project folder an exception not found is caused..If I have it outside Laravel's folder I heve a problem with the root path...Any ideas..?
It's not a good idea to put a 3rd party application in the /public/ folder of you laravel app. Instead you can put your /pma/ folder at root level and point a new subdomain (like pma.yourproject.com) to that folder.

Publish an angular web app with codeigniter Rest

I have made a web app with angular 5 and a Codeigniter Rest (two separated folders) and now i want to put it on a free host to try it.
But someone told me to integrate my front part (angular) inside my back part (codeigniter). But i can't figure this out.
Does someone have some link for a tuto about this please ?
You can host your both backend and front end in apache server. Put the backend code in the home dir inside some other folder. For angular you can try the command from the root dir of angular from your local machine ng build --prod make sure to change the api urls in it to the hosted php url. Once the build is completed it will create a folder named dist. You can copy that into your websites public directory. Please keep in mind that once you made a change you have to take build again and upload it. I don't know any other ways exists for that. For the backend upload your db and change it's settings accordingly first. Make sure you are able to call the api.