[Solved] png format images are not stored in my server [closed]


I tried to make your code a bit more clear, and help you find what is happening on your code, use the var_dump() to see the values.

Of course all the $_REQUEST and $_SERVER should be correct.

    // initialize variables
    $file_name1 = false;
    $document_root = false;
    $request_c3_len = false;
    $fragment = false;
    $mime = false;

    // check what information is available
    if ( isset( $_SERVER['DOCUMENT_ROOT'] ) !== false ) {
        $document_root = dirname( $_SERVER['DOCUMENT_ROOT'] );
    }
    if ( isset( $_REQUEST['c3'] ) !== false ) {
        $request_c3_len = strlen( $_REQUEST['c3'] );
        $fragment = substr( $_REQUEST['c3'],( $request_c3_len - 4 ), $request_c3_len );
    }

    if ( ( $document_root !== false ) && ( $fragment !== false ) ) {
        $file_name1 = $document_root.'/CDN/image/'.$t."1".$fragment;
    }
// var_dump( $file_name1 );
// exit( __FILE__.' '.__LINE__ );



    // work only if necessary
    if ( ( $file_name1 !== false ) && ( isset( $_REQUEST['c13'] ) !== false ) ) {
        $mime = str_replace( 'data:image/jpeg;base64,', '',$_REQUEST['c13'] );
// var_dump( $mime );
// exit( __FILE__.' '.__LINE__ );       
        file_put_contents( $file_name1, base64_decode( $mime ) );
    }

Check at each step that you have the information that you expect.

1

solved png format images are not stored in my server [closed]