Search code examples
laravelflutterxampp

Weird Laravel/Xampp behavior upon accessing old and newly uploaded file


I'm accessing an image with this :

http://MyServerIP/storage/motorcycle/Image.jpg

if the image is already inside the project directory before XAMPP installed, it works!

C:\xampp\htdocs\m2mobileapp-backend\storage\app\public\motorcycle

But when the image is uploaded from my Flutter app via Laravel to save it locally to my server after installing XAMPP, the uploaded image can not be accessed it's always ended with 404 | Not Found Laravel page. I've make sure that the image directory, image name & extension, and the URL is all correct. and that newly uploaded image is really exist on my server folder :

C:\xampp\htdocs\m2mobileapp-backend\storage\app\public\motorcycle

that newly uploaded image can be accessed if i'm reinstalling XAMPP. But it's different when i'm using my local IP PC address the newly uploaded file can be accessed right away after i uploaded it.

do u guys know why? i'm sorry i'm still new my words might be wrong but i hope u guys understand my English. Thankyou!


Solution

  • 1st try this : php artisan serve --host [YourIP] --port 80 then Restart Apache/XAMPP

    if it's still not works, uninstall XAMPP and switch to Laragon.

    If u're facing issues with Laragon about "QueryException, could not find driver"

    U can follow these steps below :

    1. Make sure u're editing the right php.ini, because sometimes laragon is directing you to the wrong php.ini
    2. To locate the find the correct php.ini use "php --ini" on cmd.
    3. After u find and open the correct php.ini uncomment: extension=pdo_mysql

    I don't know why it works, i'm still new on Laravel and programming would love if someone can explain why. It left me curious as the solution is just randomly happened why i try various of things hahah