SVG Images

See all posts See thread Reply

Re: SVG Images new!
by colin, 6 years, 4 months ago
Your system doesn't detect MIME property. It should be image/svg+xml. You can try to deactivate MIME detection using FileInfo by setting mime_fileinfo to false in the function init() but best is to fix your system.Reply
Re: SVG Images new!
by Dave Buchholz, 6 years, 4 months ago
ok, thanks I will look into thatReply
Re: SVG Images new!
by Dave Buchholz, 6 years, 4 months ago
Just following this up, disabling mime_fileinfo gave me the correct file extension see log below but something that struck me was that when I did a print_r on $_FILES it has the correct mime type there ?

print_r($_FILES) gives Array
(
[src] => Array
(
[name] => cogs.svg
[type] => image/svg+xml
[tmp_name] => /usr/tmp/phpmyNgBK
[error] => 0
[size] => 3385
)

)

logs for this upload

system information
- class version : 0.35dev
- operating system : FreeBSD
- PHP version : 5.6.36
- GD version : 2.1.0
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 50M (52428800 bytes)
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
    MAGIC path will not be used
    MIME type detected as text/plain; charset=us-ascii by Fileinfo PECL extension
- MIME validated as text/plain
source variables
- You can use all these before calling process()
    file_src_name : cogs.svg
    file_src_name_body : cogs
    file_src_name_ext : svg
    file_src_pathname : /usr/tmp/phpmyNgBK
    file_src_mime : text/plain
    file_src_size : 3385 (max= 52428800)
    file_src_error : 0
process file to ../../uploads/slides/kitchen-test/
- file size OK
- script renamed as cogs.svg.txt!
- file mime OK : text/plain
- file name safe format
- destination variables
    file_dst_path : ../../uploads/slides/kitchen-test/
    file_dst_name_body : cogs.svg
    file_dst_name_ext : txt
- checking for auto_rename
- destination file details
    file_dst_name : cogs.svg.txt
    file_dst_pathname : ../../uploads/slides/kitchen-test/cogs.svg.txt
- cogs.svg.txt doesn't exist already
- ../../uploads/slides/kitchen-test/ doesn't exist. Attempting creation: failed
- error: Destination directory can't be created. Can't carry on a process.Reply
Re: SVG Images new!
by Dave Buchholz, 6 years, 4 months ago
Ignore that last set of logs here are the correct ones, have 2 test files and chose the wrong one!

print_r($_FILES) = Array
(
[src] => Array
(
[name] => cogs.svg
[type] => image/svg+xml
[tmp_name] => /usr/tmp/phpr4j7ar
[error] => 0
[size] => 3385
)

)

Logs:
system information
- class version : 0.35dev
- operating system : FreeBSD
- PHP version : 5.6.36
- GD version : 2.1.0
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 50M (52428800 bytes)
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Fileinfo PECL extension deactivated
- Checking MIME type with UNIX file() command
    MIME type detected as image/svg; charset=us-ascii by UNIX file() command
- MIME validated as image/svg
source variables
- You can use all these before calling process()
    file_src_name : cogs.svg
    file_src_name_body : cogs
    file_src_name_ext : svg
    file_src_pathname : /usr/tmp/phpr4j7ar
    file_src_mime : image/svg
    file_src_size : 3385 (max= 52428800)
    file_src_error : 0
process file to ../../uploads/slides/kitchen-test/
- file size OK
- file mime OK : image/svg
- file name safe format
- destination variables
    file_dst_path : ../../uploads/slides/kitchen-test/
    file_dst_name_body : cogs
    file_dst_name_ext : svg
- checking for auto_rename
- destination file details
    file_dst_name : cogs.svg
    file_dst_pathname : ../../uploads/slides/kitchen-test/cogs.svg
- cogs.svg doesn't exist already
- ../../uploads/slides/kitchen-test/ doesn't exist. Attempting creation: failed
- error: Destination directory can't be created. Can't carry on a process.Reply
Re: SVG Images new!
by colin, 6 years, 4 months ago
The MIME type in $_FILES is sent by the client, and cannot be trusted. It is used only if all the server-side MIME detections fail.Reply
Re: SVG Images new!
by Dave Buchholz, 6 years, 4 months ago
ok, that makes sense

thanksReply