try upload mxf file used codeigniter, but not upload to server - codeigniter

I try upload mxf file used codeigniter upload helper, but get 404 error when i try called, this is because the file no upload to server.
the file is name.MXF
$this->upload->display_errors() return
The filetype you are attempting to upload is not allowed.
this is strange, because in $config["allowed_types"] It is added the filetype
I can upload others type files in the same folder, therefore isn't a problem the permission or htaccess.
code example:
contoller
public function uploadFile(){
$config["allowed_types"] = 'MxF|mxf|MXF';
$folder= './uploads/';
if (!file_exists($folder)) {
mkdir($folder, 0777, true);
}
$config["upload_path"] = $folder;
$this->load->library('upload', $config);
$this->upload->initialize($config);
$FileName="name";
$this->upload->do_upload($FileName);
}
htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|assets|js|uploads|)
RewriteRule ^(.*) index.php?/$1 [QSA,L]
how i can upload this type files?
please help me!
SOLUTION
I found answer in this link and setting the "allowed_types" = '*' Codeigniter: The filetype you are attempting to upload is not allowed

Try adding the following key/value pair to application/config/mimes.php
'mxf' => 'application/mxf',
Note the comma at the end of the above line. If you put this new line at the end of mimes.php (after 'ico' in my installation) be sure to add a comma to the previous line. After all, you are adding another entry into an array.
This addition should help the upload class set the header properly.

Related

How to setup a Laravel app in a subdomain-directory in a shared host?

I want to access my Laravel application through a directory in a subdomain in a shared host; as in sub.domain.com/dir. I want to be able to properly hit the app routes as sub.domain.com/dir/posts.
Thus, I've set the APP_URL=https://sub.domain.com/dir/ in the .env file. It works through sub.domain.com/dir/public; but the relatively-addressed media are inaccessible; they are referenced as sub.domain.com/path/to/asset, while they should be sub.domain.com/dir/path/to/asset:
sub.domain.com/dir/path/to/asset <--- accessable: Expected
sub.domain.com/path/to/asset <--- inaccessable: What is given
In an attempt to drop the /public part, I've put the following code in an .htaccess file inside of <docroot>/dir directory:
RewriteEngine On
RewriteRule ^(.*)$ /dir/public/$1 [L,QSA]
It seems to be effective on dropping the /public part (let me know if there are issues with that).
Here is the main issue: considering the web.php file to be like:
Route::get('/{num}', function ($num) { return "Number: $num"; })->where('num', '\d+');
Route::get('/{any}', function ($any) { return "Other: $any"; })->where('any', '.*');
Accessing sub.domain.com/dir/123, gets Other: dir/123 instead of Number: 123: Laravel considers the /dir/123 as the routing matter, while I want it to treat the /123 as the routing matter. The same issue causes the assets to not to originate from sub.domain.com/dir but rather from the subdomain root: sub.domain.com, without the /dir suffix).
I want the sub.domain.com/dir to be considered as a whole (as if the /dir is part of the domain, in that the relatively-addressed media would be accessible); and what follows the /dir part, to be fed into Laravel app for routing and all the other stuff.
So, how should I setup my Laravel app in a subdomain-directory in shared host?
Put these lines of code in your laravel root directory .htaccess file, which might be in your sub.domain.com/dir directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
that will solve your /public problem.
For the Media assets, did you used the asset URL helper function to link the media assets?

laravel routing returning 404 without using index.php

I am having a small issue creating a dynamic sitemap.xml for the site.
My routing file:
Route::get('sitemap.xml', [
'uses' => 'PageController#sitemapXml',
'as' => 'user.page.sitemapxml'
]);
My controller:
public function sitemapXml(){
....
$content .= '</urlset>';
return response($content, 200)->header('Content-Type', 'text/xml');
}
My issue:
To access get the correct response i have to use the following route:
www.mysite.com/index.php/sitemap.xml
However, if i do www.mysite.com/sitemap.xml, i get a 404.
If i manually add the sitemap.xml file in my public folder, i can access the file i just added, but not the dynamic one created in my controller.
My research:
Its probably a problem with the server and not laravel itself. Apparently, .xml extension are not processed through the normal routing.
It suggests adding:
location = /sitemap.xml {
try_files $uri $uri/ /index.php?$query_string;
access_log off;
log_not_found off;
}
that did not work.
I also tried the changing my .htaccess to this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
as specified in the docs
My question:
Is their anything I can do laravel-wise to handle .xml requests?
Also, if you could guide me towards anything that might help me understand this process better, its very welcomed.
Thank you in advance for taking the time to help
UPDATE:
if instead of using my localhost, i use "php artisan serve", things work correctly without any issue.
I found the answer on this link:
https://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116
I changed my .conf file and voila.
Hope this helps you
Just to clarify: Nothing wrong with Laravel. More server specific.

Code Igniter doesn't recognize my function in controller under a folder

I have a folder under my main controller-folder called admin, in that controller i have a file name admin.php which has a function xyz.
I want to access that function using this url
http://localhost/webroot/admin/xyz
However when I try to access it, it is giving me this error.
404 Page Not Found
The page you requested was not found.
this is code of my routes.php file
$default_controller = "welcome";
$controller_exceptions = array('welcome','forum');
$route['default_controller'] = $default_controller;
$route["^((?!\b".implode('\b|\b', $controller_exceptions)."\b).*)$"] = $default_controller.'/$1';
$route['404_override'] = '';
$route['admin'] = "admin/admin";
This is my .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Also mod-rewrite is enabled :)
Please let me know why is it not working and how can i make it work. Any kind of help is really appreciated. Thanks
Ensure that your routes are stored in application/config/routes.php (not router.php as specified in your question). Try adding a route that uses a wildcard, like this:
$route['admin'] = "admin/admin"; //Routes to 'index()' function
$route['admin/(:any)'] = "admin/admin/$1"; //Handles all other cases
:any will match a segment containing any character(s), after the admin segment, and will pass it/remmap it to the the admin controller.
The user guide contains more information on controllers in sub-folders and routing.

Image relative and absolute path and .htaccess

Hy all,
I'm playing around in Codeigneter and trying to make some kind of photo album just for fun ( to understand codeigneter better before i start for real ).
Now did i set up a test website here:
http://foal.scriptsenprogs.nl/
Now the thing is that users can upload an image in the future. And i want that image to be some kind of save...
So if somebody use this link:
http://foal.scriptsenprogs.nl/media/img/albums/1.png
It should be blocked (like it is now).
I've got this line of code in an .htacces file that is placed in /media/img/albums folder
<Directory "http://foal.scriptsenprogs.nl/media/img/albums" >
Options Includes
AllowOverride All
Order allow,deny
Deny from All
</Directory>
I must confess that i have little know-how about .htaccess files, but this seems to work ( the direct url is blocked ).
In my codeIgneter code i use this to add an image to an webpage:
$str .= '<div style="margin-top:20px;"><img width="200px" src="./media/img/albums/' . $imageStuff[$row['album_id']] -> img_id . '.' . $imageStuff[$row['album_id']] -> img_type . '" /></div>';
And before the .htaccess file, it worked. But now it isn't working.
If i check chromes error console i see this error:
GET http://foal.scriptsenprogs.nl/media/img/albums/1.png 404 (Not Found) foal.scriptsenprogs.nl:48
So an 404 Not Found error it is then. But if you check the URL you see that it is conferted to an Absolute URL? But i inserted an Relative URL right?
Any thoughts of you guys on how to fix this?
EDIT 1
In de webroot of the subdomain, i've got the following .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|school|media|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
EDIT 2
To clarify the question something more...
If your on the website ( http://foal.scriptsenprogs.nl/ ) the image must be showable done by using an relative path. ( like this: <img width="200px" src="./media/img/albums/1.png" /> )
But if your trying to acces the image through an absolute path, it must be blocked ( the link will be something like this then: http://foal.scriptsenprogs.nl/media/img/albums/1.png )
Sometimes CI and relative urls don't play nice together, try using the base_url function
'src="'.base_url().'media/img/albums/'
You could add a new rule to your existing webroot/.htaccess file.
Place the following after the RewriteEngine On line towards the top of your file.
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png|jpg)$ /404.html [L]
This restricts access to any jpg,gif, etc to the domain http://yoursite.com, other requests are redirected to a 404 page.
NOTE: If you are testing this on a local server, you will be on the same domain as your site so it will most likely seem like nothing is happening.

Codeigniter URI Segment Not Working properly online

Please have a look at the following url:-
English: http://www.santinepal.com/demo/en
Nepali: http://www.santinepal.com/demo/np
The codeigniter profiler is ON but it shows
URI STRING
No URI data exists
The $this->uri->segment(1); shouldve returned en or np but it reruns nothing.
This works fine on my localhost.
my routes.php file has:-
$route['default_controller'] = 'front';
$route['backend'] = 'backend/sentry';
// URI like '/en/about' -> use controller 'about'
$route['^(en|np)/(.+)$'] = "$2";
// '/en' and '/fr' URIs -> use default controller
$route['^(en|np)$'] = $route['default_controller'];
Check that your .htaccess file is the same on the server and that URL Rewriting is enabled.
Navigating to http://www.santinepal.com/demo/index.php/en shows the URI segments working, so it must be server configuration issue.
I've had something similar, turns out some server setup caused the issue. Try changing your .htaccess file that removes the index.php to this:
#CODE IGNITER - REMOVE INDEX.PHP
RewriteCond $1 !^(index\.php|resources|file_uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
The last line is the only one that is different, there is a ? after the index.php.

Resources