Image class intervention not readable!
can anyone help me that why image not readable error show on deployment when i upload new photos to laravel project,
which is totally fine in development environment but in production has this error
enter image description here
AND this my intervention code in controller
if($request->hasFile('file')){
$nameWithExtension = $request->file('file')->getClientOriginalName();
$extension = $request->file('file')->getClientOriginalExtension();
$fileName = pathinfo($nameWithExtension, PATHINFO_FILENAME);
$newFileName = $fileName.'_'.time().'.'.$extension;
$upperExt = strtoupper($extension);
if($upperExt == 'JPEG' OR $upperExt == 'PNG' OR $upperExt == 'JPG' OR $upperExt == 'GIF'){
$request->file('file')->storeAs('public/doctor/',$newFileName);
$request->file('file')->storeAs('public/doctor_small/',$newFileName);
$request->file('file')->storeAs('public/doctor_small2/',$newFileName);
//Resize image here
$thumbnailpath = public_path('storage/doctor_small/'.$newFileName);
$img = Image::make($thumbnailpath)->resize(520, 668, function($constraint) {
$constraint->aspectRatio();
});
$img->save($thumbnailpath);
$thumbnailpath2 = public_path('storage/doctor_small2/'.$newFileName);
$img2 = Image::make($thumbnailpath2)->resize(100, 100)->save($thumbnailpath2);
}
}
Whenever I see this type of question, everyone answers that you should store it in the public folder of the project. says use this storage: link but it is not always like this, you should bear in mind that if you upload the folder in two different projects one public_html and another in a folder called for example my project things will be stored in the folder my project and laravel will search for them in public_html where they don't exist, a solution would be to put the whole project in public html by changing the .httacces this way
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule ^ index.php [L]
</IfModule>
Related
In my codeigniter project, i am working around the url parameter. Its almost working but there is some problem in the view page which is loading.
I have set all the configuration as per my knowledge. But I doubt there must be some issue in the .htaccess or routes.php file.
.htaccess file --
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
routes.php --
$route['default_controller'] = 'home';
$route['home'] = 'home/index';
$route['faq'] = 'home/faq';
$route['privacy-policy'] = 'home/policy';
$route['doupnow-videos'] = 'home/videos';
$route['doupnow-audios'] = 'home/audios';
$route['morevideo/(:any)'] = 'home/morevideo/$1';
$route['moreaudio'] = 'home/moreaudio';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Controller Page --
public function morevideo($cat)
{
$result['list']=$this->Home_Model->displayVideosAll($cat);
$this->load->view('header');
$this->load->view('doupnow-video-more', $result);
$this->load->view('footer');
}
Now when i navigate to "http://doupnow.com/morevideo/latest", this page getting the parameter correctly and also displaying the data based on the parameter only but the view is not getting the html and css elements like the other pages.
Kindly give me the proper direction. Thank You.
On your site, when you're linking to a script or stylesheet, you link it by doing:
/js/script.js
But you need to give the full url like this:
http://doupnow.com/js/script.js
I am working on codeigniter 3.1.8. It works fine on my localhost. However, when I push it to FTP server, I can only access the the default controller page. When I tried to access other view that has other controller, it gives me error '404 Not Found'
config :
$config['base_url'] = 'https://*****.net/my_project/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['enable_hooks'] = FALSE;
$config['encryption_key'] = 'xRUqKhsoZ5qV6y3kqARFJFdPqJvp7X2z';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
route :
$route['default_controller'] = 'main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I have tried several .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /materials-library/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
and
<IfModule mod_rewrite.c>
RewriteEngine On
# Set the rewritebase to your CI installation folder
RewriteBase /sandbox/ci/
# Send everything to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Any help will be very appreciated. Thanks!
Try this, it's working for me. Make sure The file must be called ‘Yourcontroller.php’, with a capital ‘Y’.
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Make sure you have loaded uri library (application/config/autoload.php)
$autoload['helper'] = array('url', 'file');
Check out controller naming convention here:https://www.codeigniter.com/userguide3/general/controllers.html. Hope this will help you.
Greeting!
it's normal problem and For fixed it you have to define .htaccess file in you folder. as bellow
both file in your folder.
put this file in your main folder and assign name Of .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
put this file in your application folder and assign name Of .htaccess
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
1) first controller name and class name first character capital letter
example :: CapturistaCtrl
2) go to config changes ::
-> $config['index_page'] = 'index.php'; remove index.php
-> $config['uri_protocol'] = 'REQUEST_URI'; remove (REQUEST_URI)
3) .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
set .htaccess file
List item
Routes not working and default controller showing error 404 when I am setting welcome as a default controller then all routes defined with the welcome controller working but my other routes and url not working.
$route['default_controller'] = "welcome";
$route['testRoute'] = 'welcome/test';
$route['testRoute/(:num)'] = 'welcome/test/$i';
All above routes are working with only welcome controller.
$route['default_controller'] = "login";
$route['loginMe'] = 'login/loginMe';
$route['logout'] = 'user/logout';
Showing error 404 for all controllers and functions.
If you put index.php after domain this will work.
http://www.example.com/index.php/login/
You should remove index.php from url by replacing in config and .htaccess
replace in config.php
$config['index_page'] = 'index.php';
by
$config['index_page'] = '';
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$0 [L]
This is what worked for me:
In config.php of config folder, use: $config['enable_query_strings'] = FALSE;
Use $config['uri_protocol'] = 'AUTO';
Use $config['index_page'] = '';
Also remember to set your base url. Mine is: $config['base_url'] = 'http://localhost/code';
Finally use the following htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /code/index.php/$1 [L]
</IfModule>
NB: Remember to edit your path to index.php in the htaccess file. Hope this works for you
I'm trying to setup codeigniter for our website.
if I want the main page to be http://example.com
and my folder structure looks like this:
public_html\
application\
common\
system\
how do I setup codeigniter to show the page when going to http://example.com? I'm getting a 404 error when viewing it.
I edited config.php, but im not sure what to put for my base url.
my htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
my routes.php
$route['default_controller'] = "HomeController";
$route['404_override'] = '';
my HomeController.php
public function index()
{
$this->load->model('HomeModel');
$this->load->view('templates/header');
$data['result'] = $this->HomeModel->function1();
$this->load->view('index', $data);
$this->load->view('templates/footer');
}
my HomeModel.php
<?php
class HomeModel extends CI_Model{
public function index()
{
}
public function function1()
{
$query = $this->db->get('work_orders');
//return $query->result();
return $query->result_array();
}
}
EDIT2:
Edit your default_controller from HomeController to homecontroller Like this:
$route['default_controller'] = "homecontroller";
and rename (if needed) your controller from HomeController.php to homecontroller.php and in your Controller itself call it Homecontroller.
Do the same for the model. call it homemodel.php (or home_model.php) in your directory and Call it Homemodel in your model itself.
Also clear your browser cache.
EDIT1:
Rename your model. I guess you called your model HomeModel.php. just call it home_model.php. this should fix your problem.
Your .htaccess file should look like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
This is just copied from my server and it works great.
After then, change your default_controller to:
$route['default_controller'] = "the default controller";
and if public_html is a folder you created your index page should be:
$config['index_page'] = "public_html/";
otherwise leave it blank. (if it's your server's httpdocs)
should work :)
At your router.php in config folder there is an line
$route['default_controller'] = "your controller name";
add your controller that you want to display defaultly
You can make base_url empty:
$config['base_url'] = '';
Try this working .htaccess conf:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
IF nothing helps then hosting doesn't support mod_rewrite apache module
I'm stuck with redirect loop when I deploy the files from localhost to my server.
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
The site is multilingual and I'm using .htaccess file to remove the index.php from the uri. I'm trying to deploy the site to a subfolder in my domain (i.e http://www.mydomain.com/subfolder) and ideally I want the urls like this (http://www.mydomain.com/subfolder/en/welcome)
My .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
I have also tried:
RewriteEngine on
RewriteBase /subfolder/
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
My config.php:
$config['base_url'] = 'http://www.mydomain.com/subfolder/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
My routes.php:
$route['default_controller'] = "home";
$route['404_override'] = '';
$route['^../products/(:num)'] = "products/products_list/index/$1";
$route['^../products'] = "products/products_list/index";
$route['^../products/detail/(:num)'] = "products/product/index/$1";
$route['^../(.+)$'] = "$2";
And finally MY_Config class for i18n:
class MY_Config extends CI_Config {
function site_url($uri = '')
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
if (function_exists('get_instance'))
{
$CI =& get_instance();
$uri = $CI->lang->localized($uri);
}
return parent::site_url($uri);
}
}
This setup works fine in my local environment, I access via http://local.subfolder.com, I set a virtual host to do this, but this setup doesn't work when I deploy to the server in a subfolder.
I would be really glad if someone can point where the problem is. Sorry for the long post, but wanted to give as much as information.
Thanks in advance
I'd try removing the trailing slash from RewriteBase
RewriteBase /subfolder
And also modifying your RewriteCond
RewriteEngine On
RewriteBase /subfolder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I've noticed that using the ? before /$1 seems to work sometimes in CI too.
Very useful doc:
http://codeigniter.com/wiki/mod_rewrite/
if u want to use the htaccess for a particular folder., u just put your htaccess with in that folder. for ex.,
if ur using five virtual hosting like v1,v2,v3,v4,v5. And if u want to use your htaccess in v3, just put that file within that folder.