file - PHP: Encode image Base64 local -


I want to convert an image into base 64 and insert it into my database. I know how to encode an image in base 64, but I do not know how to use a file from a user.

Then the user " and type =" file "/> but how can I access that file without downloading the file and store it on my server / I can?

so file I want to localize locally on your computer will

Thank you

BLOB datatype to store files is the best.

  • it is very well end up
  • this See also:
  • MySQL are some interesting comments

    If you do not want to save the file in the database, but just read it, use:

      & lt; form method = "post" enctype = "multipart / form-data" & gt; & lt; table width = "350" border = "0" cellpadding = "1" Selspesing = " 1 "class =" box "& gt; & LT; TR & gt; & Lt; td width =" 246 "& gt; & lt; input type =" hidden "name =" MAX_FILE_SIZE "value =" 2000000 "& gt; & lt; input name = "userfile" type = "file" id = "userfile" & gt; & Lt; / TD & gt; & Lt; Td width = "80" & gt; Input name = "upload" type = "submit" class = "box" id = "upload" value = "upload" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt;   
      & lt ?? Php if (isset ($ _ POST [ 'upload']) & amp; amp; Name $ _FILES [ 'userfile'] [ 'size'] & gt; 0) {$ fileName = $ _FILES [ 'userfile'] [ ' ']; $ tmpName = $ _FILES ['userfile'] ['tmp_name']; $ FileSize = $ _FILES ['userfile'] ['size']; $ FileType = $ _FILES ['userfile'] ['type']; $ Fp = fopen ($ tmp name, 'r'); $ Content = fread ($ fp, filesize ($ tmpName)); $ Content = addslashes ($ content); Fclose ($ FP);   

    $ content contains file content

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -