I statred creating project in Laravel. One of his method adds images to storage/app/public. To make this operation I had to call method:
php artisan storage:link
On my local server (I use to Xamp) it works perfectly. I have a problem after updating files on the external server. When I try open link to files in storage/app/public browser returns "error 404".
I wanted to call storage::link method on external server, but it didn't work (server blocks symlink() method).
I want to ask you do you know how resolve this problem? I have idea calling this method on local server, but with server url in parameters, but I don't know how do it.
Route::get('/storage-link', function (){
\Illuminate\Support\Facades\Artisan::call('storage:link');
});
Add this in web.php and hit the URL once and then remove it
Related
I am working locally on a webpage in laravel with wamp, everything is going smoothly except that my routes are not working I have watched youtube videos and exactly followed their instructions
Route::get('/',function(){
return view ('client-side');
});
this is returning a 404 page
also I have tried returning a simple echo with this code
Route::get('/hello', function()
{
echo 'hello man'
});
And this also returns a 404 page, I dont understand why this isnt working, ty in advance
You said you were working locally with WAMP. But you were not specific about how you were trying to access your website. So, I am wondering if you need to add public to the end of your URL. See, Laravel reads from the public directory. If you are using WAMP, then most likely you haven't don't have it reading from public.
So, let me give you an example. If you are using myWebSite as your directory from your WAMP directory, if you haven't set your hosts files, etc., then you would need to access your website like this http://localhost/myWebSite/public. Make sense?
Another way of accessing your website would be to use the built in web server. From a terminal window in the root directory of your project, type php artisan serve in the terminal window. You should then get a message that says "Laravel development server started: http://127.0.0.1:8000" so then you should be able to access your website at http://127.0.0.1:8000
Probably your problem is in calling url.
Image that your project in htdocs.So you should call your page likethis:
localhost/{YourProjectFolderName}/public/{route}
If you want remove public from url you should cut its content and past it in previous path and edit index.php file.
If you want remove {YourProjectFolderName} from your url you should edit config of wampp.
I'm struggling with Laravel 5.7 issue. When I'm trying to open in my app PDF file from my storage/public it shows 404 error. I've already linked storage to public by php artisan storage:link. The problem occurs on my hosting web server (I guess it's powered by LiteSpeed). On my local server everything works by calling source from assets($path) like here, but on my VPS server I had to make source to file static this way. On my web server I can't use any of these, because it calls 404. The funny thing is I've got images in the same folder also, and it works properly linked by assets($path) but PDF files show 404 error. What's the problem?
Url should be absolute
Skan {{ $pdf->ID }}
or
Skan {{ $pdf->ID }}
I created a PHP script that will be called once a day by the cron job.
The cron job works fine and creates a HTML Email template.
I have a development(localhost) environment and a test environment.
My only issue is inside the HTML Email template, there is an image that isn't rendering on my test environment. If I inspect the element, the image path is set to localhost/images/image_name.jpg. I don't understand why in test environment the path is set to localhost; it should be testdomain/images/image_name.jpg instead of localhost/images/image_name.jpg.
If I manually call the script through the browser in the url, I get the correct image path, and the image is fine in test environment.
Why does it work when calling it manually and not when it is called by the cron job?
Yes, I'm autoloading the url helper in the autoload.php file.
Here is my image
<img src="'. base_url() .'images/image_name.jpg" alt="" />
I'm tempting to load the url helper inside the PHP file and wait tomorrow to see if that works.
Any ideas what is causing this problem?
Thanks
Base URL should be absolute, including the protocol:
$config['base_url'] = "http://somesite.com/somedir/";
If you are leaving it empty CodeIgniter will try to autodetect the url.
Basically, if your $config["base_url"] isn't set, CodeIgniter tries to figure it itself from $_SERVER['HTTP_HOST'].
So, when you access to the testdomain, the content of $_SERVER['HTTP_HOST'] is testdomain.
But if you let server access it from http://localhost/ it is "localhost"
This is probably why it does not work. You should either set a base url in $config["base_url"], or (not recommended) hardcode the domain into the <image> tag.
Edit:
You can also try giving it a dynamic-ish base url, check the below code:
$config["base_url"] = !isset($_SERVER['HTTP_HOST']) || $_SERVER['HTTP_HOST'] == "localhost" ? "http(s)://testdomain/" : '';
I figured it out. The image is hosted on a private server. When I call the script through the browser (for testing purpose), the image is fine because I'm logged in as a user. The story is different when it is called by a cron job. When the cron job calls the script, the web app has no idea who you are. The purpose of the cron job, it to send out an email after 3 days registering, and when a customer receives the email, the image is broken because it is hosted on a private server. Since we are working on 3 different web apps and one of them is a public server, I stored the image on that public server and added a constant to point to the new location on the public server. Even though we are working on 3 different web apps, all apps are somewhat connected to each other, and it made sense to store the image on a public server.
I have a project in symfony and apache, also, I have a web/images folder where I store some images.
The problem is that when I type the following url: mydomain:app_dev.php/images/myimage.png
I get back this error:
No route found for GET /images/myimage.png
Any other url works fine.
Why is this happening? why cant this just be like a plain apache website where you type in the image url and get it back?
Thanks
Links that use static content should not use app_dev.php or app.php. This will allow it to be retrieved as if it was a 'plain apache website' or what ever web server you are using.
This should work the way you want it to.
mydomain:images/myimage.png
I just finished testing the website on Windows server. The whole website was being made and tested in Windows environment. Everything is working fine but as I launch the website to a server with UNIX environment, I am getting the following error.
http://wevte.com/test/
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.
Solved the issue by chainging the controller file name as home_Controller from Home_Controller..