I have a Laravel project hosted in CPanel and it’s running but when I upload an image, it supposed to store in the public folder like ("public_path()/posts/theactualimage.jpeg").
in my local machine things are going pretty well but not on the hosted
I don’t know if there’s any configuration that I should do …
here is the structure of the folders
./
| public_html
| | posts
| | index.php
| | some other files
|
| myapp
| | all the other files controllers views
here is the function that stores the images
public function uploadImage($location, $imageName){
$name = $imageName->getClientOriginalName();
$imageName->move(public_path().'/'.$location, date('ymdgis').$name);
return date('ymdgis').$name;
}
the uploaded image is automatically creating new folder inside myapp/public/posts/(image.jpg)
if possible please log the public path and location, see if you getting expected results
Related
Before you assume, I did read ALL other posts on this problem and I was unable to find a solution to my problem.
So the thing is, however and wherever i upload my files and folders on my web host i get the same result giving me the "currently unable to handle this request. HTTP ERROR 500". I'm using the 000webhostapp.
So I uploaded the project in my root directory "/", content of the public to the public_html project, and it gave me the text above. Then I tried moving my whole project into the public_html(public was its own directory inside public_html) and it gave me the same result. I've tried some solutions with .htaccess file but whatever I tried won't make it work. In my localhost project is installed somewhat like this "htdocs/kola/..", but on the web hosting it is just in the root, no other dir(that's something I think might help but I'm unable to use). So after 30 hours of trying and reuploading the project 5 times, still can't make it work and I'd be rather grateful if someone could even try to help me with this.
Thanks in advance
The right way is to get to the root of your folder ... ie /home/ and create a folder for your project. Then move the all the contents of your project into this folder except the public folder. Now go to the public_html folder and add all the contents of the public folder there.
Update your index.php as below:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../(name of your root folder)/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../(name of your root folder)/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
Configure the .env file and have the right database configuration.
Need not to create new dir. Just delete the content of index.php file and paste the above code and replace your (name of your root folder) with public_html.
im trying to install Laravel in my shared hosting website's(which is not laravel) subfolder.
for example in: example.com/dev
Structure:
->laravel
->app
->bootstrap
->public_html
...example.com folders & files
->dev
->css
->js
->.htacess
->index.php
... other Laravel public files
My example.com/dev/index.php looks like this:
... laravel codes
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../../laravel/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
... laravel codes
Problem:
When i try to enter http://example.com/dev/ browser throws error:
This page isn’t working
mysite.com didn’t send any data.
ERR_EMPTY_RESPONSE
THERE ARE NO ANY INFORMATION/SOLUTION FOR THIS PROBLEM IN THE INTERNET.
ANY SOLUTION?
Your entire project should be inside your public_html folder. Then move all the contents of your public folder to public_html as well. Then edit your index.php to match the proper directory for autoload.php and app.php
From your text I assume you want call Laravel via http://example.com/dev/ If you hoster allows symlinks, you can try this.
-> laravel
-> app
-> ...
-> public // symlinked to public_html/example.com/dev
-> ...
-> public_html
-> example.com folders & files
-> dev // This is a symlink to laravel/public
A better approach in my opinion would be to create a subdomain and call Laravel like http://dev.example.com. It depends on your hoster how you can do this.
directory structure
laravel package
| |-project1
| |-app
| |-config
| |-resources
| |-project2
| |-app
| |-config
| |-resources
|-env
| and other files
|
i need the folder structure to be like above mentioned.please mention as tutorial as i am new to laravel. as i like to run multiple projects in the same laravel package without installing a new package sharing other files like env ,vendor etc.,
You could do something like this:
You can namespace all files under the app folder and prefix everything with 'project1', 'project2', etc
App/Project1/Models/etc...
App/Project1/Controllers/etc...
App/Project2/Models/etc...
App/Project2/Controllers/etc...
And in your route files, connect the routes to the different namespaces:
Route::group(['namespace' => 'App\Project1\Controllers'], function()
{
Route::get('/', 'HomeController#index');
});
You can even make different route files for different projects and load them through the RouteServiceProvider#map method...
But to be honest, I would never go this way. Laravel is so easy to load through composer, what is the problem? The whole system runs so smoothly, why try to introduce these dimensions? But if you really want to, there is always a way... :-)
I am building a frontend symfony app for a project with the current folder structure:
+---app
| +---conf
| +---lib
| | +---ca
| | | +---Search
+---frontend
| +---app
| +---bin
| +---src
| | \---PublicBundle
| | +---Controller
The app folder on root is where another (non symfony app) is located. It is a php app.
Inside the frontend folder is where symfony project is being built.
I am trying to load from inside the symfony app (from the public controller) a class from the other php app (a class inside the ca subfolder) but when I try to, symfony returns a namespace exception with the tip: Did you forget a "use" statement for another namespace?
It is correct to load a class from outside a symfony project like is, and if it is how is it done?
Thanks in advance,
I have multiple versions of the same software package in sub folders like this (simplified):
/var/www/version1
/var/www/version2
/var/www/version3
In a database I have a table similar to this:
+-----+-------------+----------+-----+
| ... | domain | version | ... |
+-----+-------------+----------+-----+
| ... | example.com | version1 | ... |
| ... | samepl.com | version2 | ... |
+-----+-------------+----------+-----+
Is there any way, using a database as a source (MySQL as an example), to map URLs to the correct subfolder based on version and domain? I would like something dynamic that does not require an Apache restart.
The purpose of this setup is to allow customers to choose which version of the software they want. If there's a better way to do this I would love to hear that as well.
Thanks!
I figured out a solution on my own that involves VirtualHost variables.
http://httpd.apache.org/docs/2.2/vhosts/mass.html