php: reversing mysql_real_escape_string's effects on binary

后端 未结 4 1697
旧时难觅i
旧时难觅i 2021-01-25 04:25

I built a webpage where users can submit a PDF which is then inserted into a MySQL database in a mediumblob for retrieval later.

This all works fine, except when the PDF

4条回答
  •  情话喂你
    2021-01-25 04:58

    Ólafur,

    I gathered that from the php manual, and even tried the following:

    $search = array( "\\0", "\\n", "\\r", "\\\\", "\\'", "\\\"", "\Z", );
    $replace = array( "\x00", "\n", "\r", "\\", "'", "\"", "\x1a" );
    $desiredString = str_replace( $search, $replace, $escapedString );
    

    This seems to works fine when dealing with text, but applying it to the binary data only further degrades PDF (e.g. paragraphs go missing).

提交回复
热议问题