Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.92 KB | None | 0 0
  1. public static final String UPLOAD_URL = "http://servidor.com/pasta/registrar.php";
  2. public static final String UPLOAD_KEY = "imagemPerfil";
  3. public static final String UPLOAD_ID = "idUsuario";
  4.  
  5. protected void onCreate(Bundle savedInstanceState) {
  6. super.onCreate(savedInstanceState);
  7. setContentView(R.layout.activity_registro);
  8. Regnome = (EditText) findViewById(R.id.editTextNome);
  9. Regsobrenome = (EditText) findViewById(R.id.editTextSobrenome);
  10. Regtelefone = (EditText) findViewById(R.id.editTextTelefone);
  11. Regcelular = (EditText) findViewById(R.id.editTextCelular);
  12. Reglogradouro = (EditText) findViewById(R.id.editTextLogradouro);
  13. Regnumero = (EditText) findViewById(R.id.editTextNumero);
  14. Regcomplemento = (EditText) findViewById(R.id.editTextComplemento);
  15. Regreferencia = (EditText) findViewById(R.id.editTextReferencia);
  16. Regcidade = (EditText) findViewById(R.id.editTextCidade);
  17. Regcep = (EditText) findViewById(R.id.editTextCEP);
  18. Regcpfcnpj = (EditText) findViewById(R.id.editTextCPFCNPJ);
  19. Regemail = (EditText) findViewById(R.id.editTextEmail);
  20. Regusuario = (EditText) findViewById(R.id.editTextUsuario);
  21. Regsenha = (EditText) findViewById(R.id.editTextSenha);
  22. Reguf = (Spinner) findViewById(R.id.spinnerUF);
  23. RegufText = Reguf.getSelectedItem().toString();
  24. result = (ImageView) findViewById(R.id.imgPerfil);
  25. }
  26.  
  27. public void abrirCamera() {
  28. Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  29. if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
  30. startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
  31. }
  32. }
  33.  
  34. public void chamarGaleria() {
  35. Intent intent = new Intent();
  36. intent.setType("image/*");
  37. intent.setAction(Intent.ACTION_GET_CONTENT);
  38. startActivityForResult(Intent.createChooser(intent, "Selecione a imagem"), SELECT_PHOTO);
  39. }
  40.  
  41. @Override
  42. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  43. if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
  44. Bundle extras = data.getExtras();
  45. Bitmap imageBitmap = (Bitmap) extras.get("data");
  46. result.setImageBitmap(imageBitmap);
  47. } else if (requestCode == SELECT_PHOTO && resultCode == RESULT_OK && data != null && data.getData() != null){
  48. filePath = data.getData();
  49. try {
  50. bitmapreme = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
  51. if (bitmapreme.getWidth() >= bitmapreme.getHeight()){
  52.  
  53. bitmapdest = Bitmap.createBitmap(
  54. bitmapreme,
  55. bitmapreme.getWidth()/2 - bitmapreme.getHeight()/2,
  56. 0,
  57. bitmapreme.getHeight(),
  58. bitmapreme.getHeight()
  59. );
  60.  
  61. }else{
  62.  
  63. bitmapdest = Bitmap.createBitmap(
  64. bitmapreme,
  65. 0,
  66. bitmapreme.getHeight()/2 - bitmapreme.getWidth()/2,
  67. bitmapreme.getWidth(),
  68. bitmapreme.getWidth()
  69. );
  70. }
  71. bitmapdest = Bitmap.createScaledBitmap(bitmapdest, 600, 600, false);
  72. result.setImageBitmap(bitmapdest);
  73. } catch (FileNotFoundException e) {
  74. e.printStackTrace();
  75. } catch (IOException e) {
  76. e.printStackTrace();
  77. }
  78. }
  79. }
  80.  
  81. public String getStringImage(Bitmap bmp){
  82. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  83. bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
  84. byte[] imageBytes = baos.toByteArray();
  85. String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
  86. return encodedImage;
  87. }
  88.  
  89. public void salvarReg(View view) {
  90. if (Regnome.getText().toString().trim().length() == 0 ||
  91. Regsobrenome.getText().toString().trim().length() == 0 ||
  92. Regcidade.getText().toString().trim().length() == 0 ||
  93. Regcpfcnpj.getText().toString().trim().length() == 0 ||
  94. Regemail.getText().toString().trim().length() == 0 ||
  95. Regusuario.getText().toString().trim().length() == 0 ||
  96. Regsenha.getText().toString().trim().length() == 0
  97. ) {
  98. mostrarMensagem("Erro", "Nenhum dos campos obrigatórios pode estar em branco. Por favor, preencha corretamente todos os campos.");
  99. } else {
  100. String str_nome = Regnome.getText().toString();
  101. String str_sobrenome = Regsobrenome.getText().toString();
  102. String str_telefone = Regtelefone.getText().toString();
  103. String str_celular = Regcelular.getText().toString();
  104. String str_logradouro = Reglogradouro.getText().toString();
  105. String str_numero = Regnumero.getText().toString();
  106. String str_complemento = Regcomplemento.getText().toString();
  107. String str_referencia = Regreferencia.getText().toString();
  108. String str_cidade = Regcidade.getText().toString();
  109. String str_uf = Reguf.getSelectedItem().toString();
  110. String str_cep = Regcep.getText().toString();
  111. String str_cpfcnpj = Regcpfcnpj.getText().toString();
  112. String str_email = Regemail.getText().toString();
  113. String str_usuario = Regusuario.getText().toString();
  114. String str_senha = Regsenha.getText().toString();
  115. String str_dataCad = Regdata.toString();
  116. String empresas = "000";
  117. String acesso = "001";
  118. String type = "registrar";
  119.  
  120. BackgroundWorker backgroundWorker = new BackgroundWorker(this);
  121. backgroundWorker.execute(type, str_nome, str_sobrenome, str_telefone, str_celular, str_logradouro, str_numero, str_complemento, str_referencia, str_cidade, str_uf, str_cep, str_cpfcnpj, str_email, str_usuario, str_senha, str_dataCad, empresas, acesso);
  122.  
  123. uploadImage();
  124.  
  125. //limpaTexto();
  126. }
  127. }
  128.  
  129. public void uploadImage() {
  130. class UploadImage extends AsyncTask<Bitmap, Void, String> {
  131.  
  132. ProgressDialog loading;
  133. RequestHandler rh = new RequestHandler();
  134.  
  135. @Override
  136. protected void onPreExecute() {
  137. super.onPreExecute();
  138. loading = ProgressDialog.show(Registro.this, "Carregando imagem", "Aguarde alguns instantes...", true, true);
  139. }
  140.  
  141. @Override
  142. protected void onPostExecute(String s) {
  143. super.onPostExecute(s);
  144. loading.dismiss();
  145. Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
  146. }
  147.  
  148. @Override
  149. protected String doInBackground(Bitmap... params) {
  150. Bitmap bitmap = params[0];
  151. String uploadImage = getStringImage(bitmap);
  152.  
  153. HashMap<String, String> data = new HashMap<>();
  154. data.put(UPLOAD_KEY, uploadImage);
  155. data.put(UPLOAD_ID, uploadImage);
  156.  
  157. String result = rh.sendPostRequest(UPLOAD_URL, data);
  158.  
  159. return result;
  160. }
  161. }
  162.  
  163. UploadImage ui = new UploadImage();
  164. ui.execute(bitmapdest);
  165. }
  166.  
  167. public void showMessage(View view) {
  168.  
  169. final String items[] = {"Câmera", "Arquivo", "Cancelar"};
  170.  
  171. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  172. builder.setTitle("Selecione a origem da imagem: ");
  173.  
  174. builder.setItems(items, new DialogInterface.OnClickListener() {
  175. public void onClick(DialogInterface d, int choice) {
  176. // Do something with the selection
  177. if (choice == 0) {
  178. abrirCamera();
  179. } else if (choice == 1) {
  180. chamarGaleria();
  181. } else if (choice == 2) {
  182. return;
  183. }
  184. }
  185. });
  186. builder.show();
  187. }
  188. }
  189.  
  190. public class RequestHandler {
  191.  
  192. public String sendGetRequest(String uri) {
  193. try {
  194. URL url = new URL(uri);
  195. HttpURLConnection con = (HttpURLConnection) url.openConnection();
  196. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
  197.  
  198. String result;
  199.  
  200. StringBuilder sb = new StringBuilder();
  201.  
  202. while((result = bufferedReader.readLine())!=null){
  203. sb.append(result);
  204. }
  205.  
  206. return sb.toString();
  207. } catch (Exception e) {
  208. return null;
  209. }
  210. }
  211.  
  212. public String sendPostRequest(String requestURL,
  213. HashMap<String, String> postDataParams) {
  214.  
  215. URL url;
  216. String response = "";
  217. try {
  218. url = new URL(requestURL);
  219.  
  220. HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  221. conn.setReadTimeout(15000);
  222. conn.setConnectTimeout(15000);
  223. conn.setRequestMethod("POST");
  224. conn.setDoInput(true);
  225. conn.setDoOutput(true);
  226.  
  227.  
  228. OutputStream os = conn.getOutputStream();
  229. BufferedWriter writer = new BufferedWriter(
  230. new OutputStreamWriter(os, "UTF-8"));
  231. writer.write(getPostDataString(postDataParams));
  232.  
  233. writer.flush();
  234. writer.close();
  235. os.close();
  236. int responseCode = conn.getResponseCode();
  237.  
  238. if (responseCode == HttpsURLConnection.HTTP_OK) {
  239. BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  240. response = br.readLine();
  241. } else {
  242. response = "Erro ao registrar";
  243. }
  244. } catch (Exception e) {
  245. e.printStackTrace();
  246. }
  247.  
  248. return response;
  249. }
  250.  
  251. private String getPostDataString(HashMap<String, String> params) throws UnsupportedEncodingException {
  252. StringBuilder result = new StringBuilder();
  253. boolean first = true;
  254. for (Map.Entry<String, String> entry : params.entrySet()) {
  255. if (first)
  256. first = false;
  257. else
  258. result.append("&");
  259.  
  260. result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
  261. result.append("=");
  262. result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
  263. }
  264.  
  265. return result.toString();
  266. }
  267.  
  268. Context context;
  269. AlertDialog alertDialog;
  270.  
  271. BackgroundWorker(Context ctx) {
  272. context = ctx;
  273. }
  274.  
  275. @Override
  276. protected String doInBackground(String... params) {
  277. String type = params[0];
  278.  
  279. String login_url = "http://servidor.com/pasta/login.php";
  280. String registrar_url = "http://servidor.com/pasta/registrar.php";
  281. String consultar_url = "http://servidor.com/pasta/consultar.php";
  282. //String excluir_url = "http://servidor.com/pasta/excluir.php";
  283.  
  284. if (type.equals("login")) {
  285. try {
  286.  
  287. String usuario = params[1];
  288. String senha = params[2];
  289.  
  290. URL url = new URL(login_url);
  291. HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
  292. httpURLConnection.setRequestMethod("POST");
  293. httpURLConnection.setDoOutput(true);
  294. httpURLConnection.setDoInput(true);
  295. OutputStream outputStream = httpURLConnection.getOutputStream();
  296. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
  297. String dados = URLEncoder.encode("usuario", "UTF-8") + "=" + URLEncoder.encode(usuario, "UTF-8") + "&"
  298. + URLEncoder.encode("senha", "UTF-8") + "=" + URLEncoder.encode(senha, "UTF-8");
  299. bufferedWriter.write(dados);
  300. bufferedWriter.flush();
  301. bufferedWriter.close();
  302. outputStream.close();
  303.  
  304. InputStream inputStream = httpURLConnection.getInputStream();
  305. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
  306.  
  307. String result = "";
  308. String linha = "";
  309.  
  310. while ((linha = bufferedReader.readLine()) != null) {
  311. result += linha;
  312. }
  313.  
  314. bufferedReader.close();
  315. inputStream.close();
  316. httpURLConnection.disconnect();
  317.  
  318. return result;
  319. } catch (MalformedURLException e) {
  320.  
  321. e.printStackTrace();
  322.  
  323. } catch (IOException e) {
  324. e.printStackTrace();
  325. }
  326. } else if (type.equals("registrar")) {
  327. try {
  328. String nome = params[1];
  329. String sobrenome = params[2];
  330. String telefone = params[3];
  331. String celular = params[4];
  332. String logradouro = params[5];
  333. String numero = params[6];
  334. String complemento = params[7];
  335. String referencia = params[8];
  336. String cidade = params[9];
  337. String uf = params[10];
  338. String cep = params[11];
  339. String cpfcpnj = params[12];
  340. String email = params[13];
  341. String usuario = params[14];
  342. String senha = params[15];
  343. String dataCad = params[16];
  344. String empresas = params[17];
  345. String acesso = params[18];
  346.  
  347. URL url = new URL(registrar_url);
  348. HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
  349. httpURLConnection.setRequestMethod("POST");
  350. httpURLConnection.setDoOutput(true);
  351. httpURLConnection.setDoInput(true);
  352. OutputStream outputStream = httpURLConnection.getOutputStream();
  353. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
  354. String dados = URLEncoder.encode("nome", "UTF-8") + "=" + URLEncoder.encode(nome, "UTF-8") + "&"
  355. + URLEncoder.encode("sobrenome", "UTF-8") + "=" + URLEncoder.encode(sobrenome, "UTF-8") + "&"
  356. + URLEncoder.encode("telefone", "UTF-8") + "=" + URLEncoder.encode(telefone, "UTF-8") + "&"
  357. + URLEncoder.encode("celular", "UTF-8") + "=" + URLEncoder.encode(celular, "UTF-8") + "&"
  358. + URLEncoder.encode("logradouro", "UTF-8") + "=" + URLEncoder.encode(logradouro, "UTF-8") + "&"
  359. + URLEncoder.encode("numero", "UTF-8") + "=" + URLEncoder.encode(numero, "UTF-8") + "&"
  360. + URLEncoder.encode("complemento", "UTF-8") + "=" + URLEncoder.encode(complemento, "UTF-8") + "&"
  361. + URLEncoder.encode("referencia", "UTF-8") + "=" + URLEncoder.encode(referencia, "UTF-8") + "&"
  362. + URLEncoder.encode("cidade", "UTF-8") + "=" + URLEncoder.encode(cidade, "UTF-8") + "&"
  363. + URLEncoder.encode("uf", "UTF-8") + "=" + URLEncoder.encode(uf, "UTF-8") + "&"
  364. + URLEncoder.encode("cep", "UTF-8") + "=" + URLEncoder.encode(cep, "UTF-8") + "&"
  365. + URLEncoder.encode("cpfcnpj", "UTF-8") + "=" + URLEncoder.encode(cpfcpnj, "UTF-8") + "&"
  366. + URLEncoder.encode("email", "UTF-8") + "=" + URLEncoder.encode(email, "UTF-8") + "&"
  367. + URLEncoder.encode("usuario", "UTF-8") + "=" + URLEncoder.encode(usuario, "UTF-8") + "&"
  368. + URLEncoder.encode("senha", "UTF-8") + "=" + URLEncoder.encode(senha, "UTF-8") + "&"
  369. + URLEncoder.encode("dataCad", "UTF-8") + "=" + URLEncoder.encode(dataCad, "UTF-8") + "&"
  370. + URLEncoder.encode("empresas", "UTF-8") + "=" + URLEncoder.encode(empresas, "UTF-8") + "&"
  371. + URLEncoder.encode("acesso", "UTF-8") + "=" + URLEncoder.encode(acesso, "UTF-8");
  372. bufferedWriter.write(dados);
  373. bufferedWriter.flush();
  374. bufferedWriter.close();
  375. outputStream.close();
  376. InputStream inputStream = httpURLConnection.getInputStream();
  377. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
  378. String result = "";
  379. String line = "";
  380. while ((line = bufferedReader.readLine()) != null) {
  381. result += line;
  382. }
  383. bufferedReader.close();
  384. inputStream.close();
  385. httpURLConnection.disconnect();
  386. return result;
  387. } catch (MalformedURLException e) {
  388. e.printStackTrace();
  389. } catch (IOException e) {
  390. e.printStackTrace();
  391. }
  392. } else if (type.equals("consultar")) {
  393. try {
  394. String nome = params[1];
  395.  
  396. URL url = new URL(consultar_url);
  397. HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
  398. httpURLConnection.setRequestMethod("POST");
  399. httpURLConnection.setDoOutput(true);
  400. httpURLConnection.setDoInput(true);
  401. OutputStream outputStream = httpURLConnection.getOutputStream();
  402. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
  403. String dados = URLEncoder.encode("nome", "UTF-8") + "=" + URLEncoder.encode(nome, "UTF-8");
  404. bufferedWriter.write(dados);
  405. bufferedWriter.flush();
  406. bufferedWriter.close();
  407. outputStream.close();
  408. InputStream inputStream = httpURLConnection.getInputStream();
  409. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
  410. String result = "";
  411. String line = "";
  412. while ((line = bufferedReader.readLine()) != null) {
  413. result += line;
  414. }
  415. bufferedReader.close();
  416. inputStream.close();
  417. httpURLConnection.disconnect();
  418. return result;
  419. } catch (MalformedURLException e) {
  420. e.printStackTrace();
  421. } catch (IOException e) {
  422. e.printStackTrace();
  423. }
  424. } else if(type.equals("uploadPerfil")) {
  425. try {
  426. String imagemPerfil = params[1];
  427.  
  428. URL url = new URL(consultar_url);
  429. HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
  430. httpURLConnection.setRequestMethod("POST");
  431. httpURLConnection.setDoOutput(true);
  432. httpURLConnection.setDoInput(true);
  433. OutputStream outputStream = httpURLConnection.getOutputStream();
  434. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
  435. String dados = URLEncoder.encode("imagemPerfil", "UTF-8") + "=" + URLEncoder.encode(imagemPerfil, "UTF-8");
  436. bufferedWriter.write(dados);
  437. bufferedWriter.flush();
  438. bufferedWriter.close();
  439. outputStream.close();
  440. InputStream inputStream = httpURLConnection.getInputStream();
  441. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
  442. String result = "";
  443. String line = "";
  444. while ((line = bufferedReader.readLine()) != null) {
  445. result += line;
  446. }
  447. bufferedReader.close();
  448. inputStream.close();
  449. httpURLConnection.disconnect();
  450. return result;
  451. } catch (MalformedURLException e) {
  452. e.printStackTrace();
  453. } catch (IOException e) {
  454. e.printStackTrace();
  455. }
  456. } else {
  457. return null;
  458. }
  459.  
  460. return null;
  461. }
  462.  
  463.  
  464. @Override
  465. protected void onPreExecute() {
  466. alertDialog = new AlertDialog.Builder(context).create();
  467. alertDialog.setTitle("Login Status");
  468.  
  469. }
  470.  
  471. @Override
  472. protected void onPostExecute(String result) {
  473. //if(result.toString().equals("usuario")) {
  474. // context.startActivity(new Intent(context, Inicio.class));
  475. //}
  476.  
  477. String s = result.trim();
  478. //alertDialog.setMessage(s);
  479.  
  480. switch (s) {
  481. case "user":
  482. context.startActivity(new Intent(context, Inicio.class));
  483. break;
  484. case "adm":
  485. context.startActivity(new Intent(context, InicioAdm.class));
  486. break;
  487. default:
  488. alertDialog.setMessage(s);
  489. alertDialog.show();
  490. }
  491. }
  492.  
  493. @Override
  494. protected void onProgressUpdate(Void... values) {
  495. super.onProgressUpdate(values);
  496. }
  497.  
  498. }
  499.  
  500. <?php
  501. require "conexao.php";
  502.  
  503. $nome = $_POST["nome"];
  504. $sobrenome = $_POST["sobrenome"];
  505. $telefone = $_POST["telefone"];
  506. $celular = $_POST["celular"];
  507. $logradouro = $_POST["logradouro"];
  508. $numero = $_POST["numero"];
  509. $complemento = $_POST["complemento"];
  510. $referencia = $_POST["referencia"];
  511. $cidade = $_POST["cidade"];
  512. $uf = $_POST["uf"];
  513. $cep = $_POST["cep"];
  514. $cpfcnpj = $_POST["cpfcnpj"];
  515. $email = $_POST["email"];
  516. $usuario = $_POST["usuario"];
  517. $senha = $_POST["senha"];
  518. $dataCad = $_POST["dataCad"];
  519. $empresas= $_POST["empresas"];
  520. $acesso = $_POST["acesso"];
  521.  
  522. //$idUsuario = $_POST["idUsuario"];
  523. $imagemPerfil = $_POST["imagemPerfil"];
  524.  
  525. $mysql_qry = "INSERT INTO `u562378822_banco`.`usuarios` VALUES (null, '$nome', '$sobrenome', '$telefone', '$celular', '$logradouro', '$numero', '$complemento', '$referencia', '$cidade', '$uf', '$cep', '$cpfcnpj', '$email', '$usuario', '$senha', '$dataCad', '$dataAcesso', '$empresas', '$acesso', null);";
  526. $verifica_qry = "SELECT usuario FROM usuarios WHERE usuario LIKE '$usuario';";
  527. $tudo_qry = "SELECT * FROM `u562378822_banco`.`usuarios` WHERE `usuarios`.`usuario` ='$usuario';";
  528. $tudo_exec = mysqli_query($conexao,$tudo_qry);
  529. $idUsuario = mysqli_fetch_array($tudo_exec);
  530. $sqldeimagem = "UPDATE usuarios SET `imagemPerfil` = '$imagemPerfil' WHERE `usuarios`.`idUsuario` ='$idUsuario[0]';";
  531. $verificador = mysqli_query($conexao,$verifica_qry);
  532.  
  533. if(mysqli_num_rows($verificador) > 0){
  534. echo "Erro. Este nome de usuario já está sendo usado por alguém. Por favor, escolha outro.";
  535. } elseif($conexao->query($mysql_qry) === TRUE) {
  536. if($conexao->query($sqldeimagem) === TRUE){
  537. $linhasAfetadas = mysqli_affected_rows($conexao);
  538. if ($linhasAfetadas == 0) {
  539. echo "Nenhuma coisa mudou";
  540. } elseif ($linhasAfetadas == 1) {
  541. echo "Imagem registrada com sucesso";
  542. } elseif ($linhasAfetadas > 0) {
  543. echo "sucesso mudaram as linhas $linhasAfetadas";
  544. } else {
  545. echo "erro";
  546. }
  547.  
  548. }
  549. //$atualizador = mysqli_query($conexao,$sqldeimagem);
  550. //$linhasAfetadas = mysqli_affected_rows($conexao);
  551. } else {
  552. echo "Erro. Os dados não foram salvos.";
  553. }
  554.  
  555. $conexao->close();
  556.  
  557. ?>
  558.  
  559. $imagem = 'myimage.png';
  560. $extensao = pathinfo($imagem, PATHINFO_EXTENSION);
  561. $dataraw = file_get_contents($imagem);
  562.  
  563. echo 'data:image/' . $extensao . ';base64,' . base64_encode($dataraw);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement