I am having problems with reading html files in php.
When you try to open html file with Arabic name using fopen(), you get an error saying the file doesn't exist.
Is there any way to make this working?
You most likely have conflict between the file system encoding and your application encoding, or some file permissions issue.
(just a guess, too few data to judge)
Related
I try to use this code to download files from my database, however, when I try to open the file, I get following errors:
when downloading file type 'docx':
Word documents are stored with the type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' (not visible on the screenshot). I believe this is correct
I solved the bug when trying a bit different code:
Downloading jpg,doc,ppt files with php are corrupted
I am trying to upload files that are named in Arabic but it is saving in folder like صناØ
I am using PHP 7 with IIS
I have tried to use iconv even the filename i am printing is coming right before move_upload_file but once this called the file store in unicode charcaters
I have tried to give header but it didn't work.
All the pages are encoded in UTF-8 with meta tags
The NTFS, if that is the file system that your system is using, doesn't support all unicode characters, sadly. Essentially, the system when it saves the file isn't able to find the characters so it is replacing it with the closest characters that are available to it.
To solve this however, you might want to change the name of the file to something that isn't using special characters while you move it. I recommend a hash (eg. md5 or other) of the file content, so that it is unique. This will store the file locally and make sure that even if a file is uploaded with characters that your system can't handle, you are still able to access the content later.
look like this is some issue in PHP as mentioned in below link:
https://bugs.php.net/bug.php?id=47096
to resolve the issue you could use php-wfio extension as a workaround. This extension provides a new protocol wfio:// for file streams and allows PHP to properly handle UTF-8 characters on the Windows file-system. wfio:// supports a number of PHP functions including fopen, scandir, mkdir, copy, rename, etc.
UTF-8 characters in uploaded file name are jumbled on file upload
I am using a library to read XLS files which internally uses PHP's zip_open() function. When creating the files locally and then uploading to my test server everything works fine. However, when I use the XLS files downloaded from a website (normal download via browser), it does not work, instead returning Error 19 meaning that the file is not seen as a zip file, which is incorrect. Excel opens the file without problems. If I re-save the file locally as an XLSX file and then upload it, I get the same error (in this instance the file is opened by the PHP's ZipArchive class). Any ideas what the reason could be? I checked that the files are not read only, possibly some Unix permissions could be set that are not displayed in Windows? (Doubt this, as the error code indicates that the file could be accessed, but could not be identified as XLS)
Using:
Apache under Windows (WAMP)
PHP 5.4.12
It seems I had misread a line of code, the zip check is only done to determine if the XLS file is an incorrectly named XLSX file. The problem with the XLS file is that it returns no sheets when parsing, I need to look into this still. I do not know why saving the XLS file as an XLSX file (using Excel) results in an incorrect ZIP archive though, but guessing it is related.
So a PHP program I built to download files from one server and upload them to another is now needed to rename the files.
For some reason I'm getting a 'invalid argument' warning on the rename() function which seems impossible because the file exists and there is 0 white space.
So now I was wondering if it was possible to rename a file as I download it from an ftp using ftp_get()?
http://php.net/manual/en/function.ftp-get.php
Would suggest so. Give it a local file name.
Also make sure you are using rename() correctly
http://uk.php.net/manual/en/function.rename.php
I am storing files into an image field in SQL server storing the string in hex after converting into using:
unpack("H*hex", $datastring);
If I read from the database and write to a file, then open the file locally I can open it up just fine. But if I try to send the file as an attachment to the browser the file becomes corrupted and unreadable. Currently, the files in question are PDF and MSWord documents.
I am setting content-type to the appropriate MIME type for the files and setting content-disposition to attachment. I've tried various ways of streaming the file including dumping the string directly from the database and writing first to a file then reading the file (either line by line or with readfile()).
I am using a slightly customized version of the Zend framework, but I'm not sure if that is causing any issues. What should I do to send files to the browser?
How do you serve them?, in theory if you are using MVC, you need to disable the view at the end of your controller to avoid extra content being inyected at the bottom of your file.