Ionic4 cordova-plugin-mobile-ocr how to set correct path of static file - ionic4

when I follow https://ionicframework.com/docs/native/ocr to integrate ocr feature, I cann't set correct path to my static image which is at /src/assets/imgs/test.png:
this.ocr.recText(OCRSourceType.NORMFILEURL, "file://path/to/image.png" /*<-this parameter*/)
.then((res: OCRResult) => console.log(JSON.stringify(res)))
.catch((error: any) => console.error(error));
I tried different combinations:
/assets/imgs/test.png
/assets/imgs/test.png
file://assets/imgs/test.png
file:///assets/imgs/test.png
...
this have frustrated me for a couple days, please help, thanks,

the first step you have to create a folder inside the assets folder (lets say its name is images) and put your image inside it.
then write this path in your code "assets/images/yourImage.png"

Related

WHMCS how to find right tpl files in pages

i'm using WHMCS and i want to make some changes in part of the page but its so hard and takes so much time for me to find the right tpl file and edit it in the template.
for example for this "search for domains" tab in this url =>
example.com/cart.php?a=add&domain=register
where is the .tpl file.
For example.com/cart.php?a=add&domain=register the file is at templates/orderforms/standard_cart/adddomain.tpl
In general, when url has cart.php, the file in cart template.
Also, you can add the following to hooks to tell you which tpl file was used for current page.
1- Create file includes/hooks/tpl_locator.php
2- Add the following code:
<?php
add_hook('ClientAreaPage', 1, function($vars) {
error_log(print_r([$vars['currentpagelinkback'],$vars['templatefile']], true), 3, __DIR__.'/tpl_file_location.log');
});
3- Visit the page you want to know which tpl file is used.
4- Result will be at file includes/hooks/tpl_file_location.log, sample below:
Array
(
[0] => /cart.php?a=add&pid=1&
[1] => configureproductdomain
)
This was tested on WHMCS 8.0
The tpl for cart.php?a=add&domain=register is actually located at /whmcs/templates/orderforms/standard_cart/domainregister.tpl if I understand your question.

Brunch asset filter

I'd like to apply a filter instead of simply copying all files over from the asset folder. (such as do not include font files if we are running in production)
Is this possible?
(If it isn't possible, can anyone give any additional insights on how I might accomplish that?)
Yeah, you will need to edit config's directive conventions.assets: https://github.com/brunch/brunch/blob/master/docs/config.md#conventions
```
config =
conventions:
assets: (path) ->
(not /\.woff/.test path) and /assets(\/|\\)/.test path
```

Where did my filename extension go in the parameter list

I am following this answer while trying to figure out how to display images located in my app directory Rails 3, displaying jpg images from the local file system above RAILS_ROOT
I've created a controller as shown there, added the match line to routes.rb, and in a test webpage I want to load up an image called test.jpg using the code
<img src="/serve_image/test.jpg" />
But I get an error saying the file <...>/public/images/test was not found.
Then I went and renamed my image so that the .jpg was gone, and then the script found my image and loaded it up as wanted.
Any ideas where the extension went? I am not sure how to debug this issue.
By default, Rails doesn't match dots in a dynamic segment. So for this route:
match '/serve_image/:filename' => 'images#serve'
:filename will only match up to the first dot it finds. So /serve_image/test.jpg will match test as the filename and will think you're expecting a JPG as a response. What you need to do is tell the router that you want to include the dot in the filename, something like this:
match '/serve_image/:filename' => 'images#serve', :constraints => {:filename => /[^\/]+/}
That will match anything except a forward slash, giving you your complete filename in params[:filename]
See the Rails Routing guide section on Dynamic Segments for more info.

How do Media Views work in cakephp?

I have arranged a file upload to happen on my application relative address: webroot/files
Now I need to force download on the uploaded files. After some googling and trying like most of the suggestions from this post I figured out the correct way to do this is using cakephps Media Views
What I have:
Main site with a table of records. Model -> Record; Table -> records;
These records have a primary key record_id.
In my database I have a Table -> files; Model -> File;
These files have a foreign key record_id and a field 'url' with the relative path to it's location.
After creating a record with files, the files are correctly uploaded to the folder, which relative address is e.g. webroot/files/record_name/file and the tables in database are correctly updated.
What I want to do:
After doubleclicking on one table row open a modal dialog with the information about the record. (done)
In this modal dialog I want to display links that will force download on these files.
I tried many variations of this:
//the retrieving of data after debug looks fine//
$this->loadModel('File');
$files = $this->File->find('list', array(
'conditions'=>array('File.record_id'=>$record_id),
'fields' => array('File.Name', 'File.Url');
))
//actual display of url
foreach($files as $file_name => $file_url) {
echo $this->Html->link($file_name, $file_url);
}
The resulting link looks exactly the way James Revillini presented
This is my actual question
Since that issue was not entirely solved, I thought it would be helpful not only for me, but for anybody who's searching for a quick solution for this problem to see a quick demonstration of how Media-views work. I have no idea where to move after making a dynamic download function:
public function download($name, $path) {
$this->viewClass = 'Media';
$params = array(
'id' => $name,
'name' => $name,
'download' => true,
'path' => $path
);
$this->set($params);
}
Point the link in the modal dialog for the resource to the download() function.
Pass the Record.id to that function. In it find the file and auto-render it.
It should work.

Input files from ExpressionEngine?

Is there a way to reference uploaded files using EE's Input class? I know it has a "post" method to get post variables, but what about files?
Not in the input class, you can just use $_FILES.
You may want to have a look at the Upload class though. For a good overview of how it works, you can check out the function _upload_file() in the Filemanager library file within your EE directory. A primer:
$this->EE->load->library('upload');
$this->EE->upload->initialize($config);
if ( ! $this->EE->upload->do_upload($field_name))
{
return $this->_upload_error(
$this->EE->upload->display_errors()
);
}
$file = $this->EE->upload->data();
The $config array contains the options for the upload, which you can review in the CodeIgniter docs.