I'm facing some problems, where i do not even have an idea how to get rid of those.
We moved our wordpress blog to a new server (Centos6, newest version of php, mysql).
We now noticed that a colleague just pasted many pictures into the wordpress editor, so that simply the base64 code is inserted into the article. This worked on the old server, but not on the new one.
If its an jpeg, it works like it used to. But if it's an png, all attributes are quotet with primes (”) and even the following normal elements are not working anymore.
This is how an element looks in the debugger:
<img class="”aligncenter”" alt="”"" src="”data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAl...”">
I checked my first ideas like mime types, but nothing helped. Then I updated php on the old server - There it still works.
The encoding of the files seem to be us-ascii (same on the old server).
The funny thing is - it works in the backend, but not in the frontend.
I have no idea. Any hints appreciated,
Best,
Kddc
Related
Our web-app has a contenteditable div we use for answering questions. Clients can paste images straight to the div (basic feature of 'contenteditable'), which turns pasted images into base64 strings.
We noticed that OSX Chrome handles the base64 decoding (encoding?) differently than other browsers. Our sample image turned into ~220 000 characters on Safari, but Chrome produced almost a million characters of base64 data.
This in turn causes an issue where the POST data is clipped, and only a part of the image is saved. All other content in the POST data that comes after the image are also clipped. The request is otherwise ok, Laravel saves the clipped data like any other and doesn't throw any errors in any logs.
PHP.ini settings should be fine (for example post_max_size=64M, php memory limit = 1024M), is there some settings in Laravel that could cause the clipping?
I am using tinymce wiris plugin for entering equations for my project. Everything is working.
The equation I entering is previously saving as MATH ML format. It had some issue in chrome. So, I had to use mathjax for fix this issue. One of the project requirement was generating doc files. It also working fine except the math-ml equation. special characters are showing the doc file instead of the equation.
I googled and found that this the wiris have a imagemode option for saving the equation as image instead of MATH ML. It worked well in chrome. But still a broken image is showing in the doc file instead of equation image. Then I checked the
plugins/tiny_mce_wiris/integration/showimage.php?formula=4ee7dd91304079fd072d156593cce168&cw=95&ch=42&cb=23.
I checked the wiris and found that a png image is saving in the cache folder while creating the issue. I am guessing instead of the above showimage.php? script link as src, it is better to show the link of the generated png image.
Unfortunately I am not able to crack that part.
Please help if you have any ideas for that.
Thanks in advance
I'm trying to save docs made by phpExcel into pdf format. Everything is fine, except for the fact that my file is very wide and doesn't fit in one page (so part of the data is lost behind the doc border)
I tried to use:
$phpExcel->getActiveSheet()->getPageSetup()->setFitToPage(true);
$phpExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$phpExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
But nothing changed. (And as I understand these only works for print version, not for converting to PDF). Does anyone has any ideas how to improve that?
I solve this issue with the following command:
$phpExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3);
So I am developing a new course-format, in which a picture is associated with each activity in a course, and presented visually. I created the course format, overrode the renderer etc. That worked all fine. However, the images are supposed to be custom generated and since it has to work for all existing and future, I put some additional code into the general course module form, enabling an image upload.
After admittedly some struggle on my part to get the File API working, it now all works fine. Only in my course format, there is an additional heading, under which you can upload a single image. This gets saved to the database fine, it is not in draft and it is viewable in my dataroots filedir perfectly if I follow the contenthash in the database. It even gets loaded into the form as a default fine. However, if I try to work with the image, all tests run fine (.is_valid_img()etc) and I even get offered to download a file. However, when I do it is corrupted and my file viewer says: "Critical Error: Not a png file". Needless to say it is not displayed on my actual course site.
When I look at the file in filedir, it very clearly is a png. Please, I would be thankful for any help, since I have tried alot and am at my wits end.
It sounds to me like you are getting some sort of output on the page before the PNG file is sent - that would be added to the start of the file and cause it not to work as a PNG file.
I would suggest you open the file in a hex editor and check the start of the file - it should look like https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header, so look for extra characters before that.
As for where the extra characters come from - they may be an obvious warning / error message (which should be easy to track down and fix). Alternatively, you may have some stray 'echo' statements (again, fairly easy to track down). The worst problems to find are extra characters before the opening 'php' tags of a file somewhere in your install or after the closing tag at the end of a file (which is why you should never use closing PHP tags). Finding these will come down to searching through all your customised code files to locate them.
I have a webservice I'm connecting to. I'm getting valid responses back for my queries, and one of them is an IMAGE type. I'm not in direct control of the DB, and they don't really offer support - so I can't ask them about the specifics.
I need to offer links to display or download this image. This should be easy enough, but I've been banging my head against this for quite a while now.
I have the IMAGE data. I have put this in a var called $evidence.
If I do the following, I get a corrupt/unreadable image across all browsers I've used (broken image link symbol or similar text):
header("Content-type: image/jpeg");
echo $evidence;
So, while debugging this I tried to display the image inline using some copy/pasta'd code:
echo '<img src="data:image/jpeg;base64,'.$evidence.'" />';
This works as expected... the image is shown correctly.
However - I need to be able to do this the correct way via a header, as I need to do other things, such as be able to force downloads.
Every time I've ever had to do anything like this, the basic "header, echo" approach has always worked. By the looks of almost every tutorial out there: this should work. It seems to be so simple, most tutorials don't even look at display problems (only data fetching problems).
Following some thinking about how data is being passed, I noticed that there was the "base64" part of the code I was using in the image tag.
I modified the echo to be as follows:
echo base64_decode($evidence);
This fixed it.
SO! 1 simple "gotcha" to help everyone else out there: make sure you have checked the data type before you display. Don't assume it's binary!