I updated PHP to PHP7, but the apache configuration went wrong. It doesn't read files directly and PHP deal with them. I did a test, I wrote <?php echo "hello world"?> into a txt file and renamed it as test.jpg. And it shows 'hello world' when you visit the jpg file. I can't find where the error is.
This is the test url: http://shouke.luopan.me/test.jpg
Try to change header content type :
header("Content-type: image/jpg");
Related
Files that are uploaded to my site have their names changed and extention change to bin. So for example a uploaded file will be dfd84848.bin, using the bin file worked fine with modelviewer but im trying to test babylon.js and it doesnt work with .bin only if i change .bin to .glb.
This code {{uploaded_asset($detailedProduct->cad_file)}} provides link like uploads/all/p1YZX9TBc7EmimFx4rXnSFKvVor8EttpOUUpylLL.bin
I want to change .bin to .glb and echo it.
i tried this
#php
$previewfile = uploaded_asset($detailedProduct->cad_file);
$replaced = Str::replace('.bin', '.glb', $previewfile );
#endphp
to show i used this <model url="{$replaced}"> but it never echoed url
Edit
So now that it echos as name.glb it doesnt work because the file doesnt exist on server. When 3d models such as .glb, .gltf are uploaded they are renamed to .bin i dont know why. The uploader is AizUploadController.php
To echo a value you should use double curly braces:
<model url="{{ $replaced }}">
Docs: https://laravel.com/docs/8.x/blade#displaying-data
I am new to openTBS,
I tried the html and php code from 'https://www.tinybutstrong.com/opentbs.php?demo' and 'https://www.tinybutstrong.com/plugins/opentbs/demo/demo_merge.php', and I can't manage to get the "$TBS->Show(OPENTBS_DOWNLOAD)" command working :
I get a page with chinese characters and no file is being downloaded.
Sample of the page :
PK鸙_S^�2''mimetypeapplication/vnd.oasis.opendocument.textPK鸙_SConfigurations2/popupmenu/PK鸙_SConfigurations2/floater/PK鸙_S'Configurations2/accelerator/current.xmlPKPK鸙_SConfigurations2/images/Bitmaps/PK鸙_SConfigurations2/menubar/PK鸙_SConfigurations2/progressbar/PK鸙_SConfigurations2/statusbar
The $TBS->Show(OPENTBS_FILE) command is working and a merged odt file is saved.
Any help would be appreciated.
Am trying to read a .docx file which is inside my project folder via PHP Word library. I have included autoloader like this :
include_once 'vendor/autoload.php'; in my controller.
CODE FOR FUNCTION IN CONTROLLER:
function test_phpword()
{
$a=base_url();
$path=$a."".'123.docx';
$source =$path;
echo date('H:i:s'), " Reading contents from `{$source}`";
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source);
echo write($phpWord, basename(__FILE__, '.php'), $writers);
}
BUT GETTING ERROR LIKE BELOW:
06:18:42 Reading contents from http://localhost/myproject/123.docx
Fatal error: Uncaught Exception: Cannot find archive file. in /opt/lampp/htdocs/myproject/vendor/phpoffice/common/src/Common/XMLReader.php:51
Try this
Change
$path=$a."".'123.docx';
to
$path='123.docx';
And put 123.docx beside your php script file. make sure the two files are in the same place. Run your php script again.
If this helps and works fine you can check the file path and make proper change to your php program.
While loading the path, you have to give relative path to the doc file as shown below,
$random_name = 123.docx;
$contents = \PhpOffice\PhpWord\IOFactory::load('../uploads/'.$random_name);
I don't know whats your $base_url, but it will not work if it is absolute path like http://path/to/doc/file.
I have worked on it and tested. Hope it helps.
I need to manipulate the openldap server database file for an app feature. I noticed that on shell it can find the openldap database file olcDatabase={1}bdb.ldif. But when I run the script from web browser from a windows host, it can not find the file. So I wrote my test script as below.
<?php
$filename = '/etc/openldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif';
file_put_contents('/var/log/file_path_data', realpath($filename));
if (file_exists($filename))
echo "find the file";
else
echo "don't find the file";
?>
When it is run from web, it can not find the file at all and escaping special characters doesn't help. I also used %3D or \x3D to replace "=" in file path for example (see http://www.ascii-code.com/), but it doesn't help either. There is no any single error reported from web browswer when it can not find the file.
This may be related to utf8 encoding or something like this in windows environment but i m not able to figure out how to fix this problem. Highly apprecitate any tips and solutions. Thanks a lot in advance!
At first just try read your file from a little bit less subdirectories.
When you find out whats chars your web server don't handle
For example create this test files :
1) $filename = '/etc/openldap/slapd.d/olcDatabase={1}bdb.ldif';
2) $filename = '/etc/openldap/slapd.d/olcDatabase=bdb.ldif';
And try read them
Is there any way to make PHPStorm apply syntax highlighting to PHP code inside a tag in an XML file?
I'm working on an OpenCart project and I'm using Vqmod, which requires that I write PHP code in an XML file. For example:
<operation>
<search position="replace"><![CDATA[
<?php echo "123"; ?>
]]></search>
<add><![CDATA[
<?php echo "xyz"; ?>
]]></add>
</operation>
1) Settings | File Types -- assign *.xml (or whatever file name pattern you think is more appropriate) to PHP files entry (you may need to remove it from "XML files" first).
This will tell PhpStorm to treat such files as PHP (it's the only way to have PHP support).
The possible negative side -- it's an IDE-wide setting and will affect ALL such files in ALL projects. Therefore -- if you can name such files in some unique way (e.g. double extension: *.php.xml or *.xml.php; unique extension: *.pxml; unique file name ending: *layout.xml) then do it.
2) Settings | Template Data Languages -- find such files (or whole folder) and assign XML in 2nd column.
This will tell PhpStorm to treat such files as "PHP with XML" instead of default "PHP with HTML".
Official manual: http://confluence.jetbrains.com/display/PhpStorm/Syntax+highlighting+of+PHP+inside+JavaScript+%28and+other+languages%29