Working on a project that use a gem named OcrSpace to perform ocr on image uploaded by carrierwave .
After a button is clicked, the text in the image would be shown in the website.
Here's the code:
<%= image_tag( @resume.attachment_url) %>
<div id="cool"> </div>
<button onclick="myFunction()">Try it</button>
<% require 'ocr_space' resource = OcrSpace::Resource.new(apikey: "xxxxxxxxx") %>
<% result = resource.clean_convert file: @resume.attachment_url %>
<script>
function myFunction() {
document.getElementById("cool").innerHTML = <%= result %>;
}
</script>
However, I got this error
No such file or directory @ rb_sysopen - /uploads/resume/attachment/3/_____2018-07-19___9.15.42.jpg
It seems that the file path is incorrect
Can anyone help me, thanks.
use
@resume.attachment.path
instead of @resume.attachment_url
url will not give you a local path to open as a file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.