Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public function store ()
  2. {
  3. // Function to store files
  4. // Save Category, LogoID as FileName into Database
  5. // Store file into "Public/logo-template"
  6.  
  7. if (Input::hasFile('logo_file'))
  8. {
  9. $file = Input::file('logo_file');
  10.  
  11. $post = new Post;
  12.  
  13. $post->category = Input::get('category');
  14.  
  15. $post->logo_id = $file->getClientOriginalName();
  16.  
  17. $file_name = $file->getClientOriginalName();
  18.  
  19. $file = $file -> move(public_path().'/logo-template',$file->getClientOriginalName());
  20.  
  21. $post->save();
  22.  
  23. $zip = new ZipArchive;
  24. $zip_path = public_path().'/logo-template/'.$file_name;
  25. $zip->open($zip_path);
  26. $zip->extractTo('./logo-template/');
  27. $zip->close();
  28.  
  29. return 'Saved';
  30.  
  31. }
  32.  
  33. else
  34.  
  35. {
  36. return 'Fail';
  37. }
  38. }
  39.  
  40. public function show ()
  41. {
  42.  
  43. $logo_id = Input::get('logo_id');
  44.  
  45. $files = array();
  46. foreach (glob(public_path().'/logo-template/'.$logo_id.'/*.png') as $file) {
  47. //$files[] = basename($file);
  48. echo "<img style='width:100px; height:100px; padding:10px;'src='/logo-template/".$logo_id."/".basename($file)."'>";
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement