PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/js/redactor/image_upload.php

https://github.com/lslucas/105fm
PHP | 34 lines | 17 code | 10 blank | 7 comment | 10 complexity | 00419f0af3f6d595d18a32d44b5b8125 MD5 | raw file
  1. <?php
  2. // This is a simplified example, which doesn't cover security of uploaded images.
  3. // This example just demonstrate the logic behind the process.
  4. // files storage folder
  5. $dir = "../../../public/images/uploads/";
  6. $_FILES['file']['type'] = strtolower($_FILES['file']['type']);
  7. if ($_FILES['file']['type'] == 'image/png'
  8. || $_FILES['file']['type'] == 'image/jpg'
  9. || $_FILES['file']['type'] == 'image/gif'
  10. || $_FILES['file']['type'] == 'image/jpeg'
  11. || $_FILES['file']['type'] == 'image/pjpeg')
  12. {
  13. // setting file's mysterious name
  14. $file = $dir.md5(date('YmdHis')).'.jpg';
  15. // copying
  16. copy($_FILES['file']['tmp_name'], $file);
  17. // $file = substr($file, 6);
  18. // displaying file
  19. $fileshow = 'http://184.72.221.135/images/uploads/'.str_replace($dir, '', $file);
  20. $array = array(
  21. 'filelink' => $fileshow
  22. );
  23. echo stripslashes(json_encode($array));
  24. }