Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Gdy uruchomię skrypt przez SSH nie generuje się obraz
lekosm2
post 15.02.2019, 20:47:26
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 0
Dołączył: 9.10.2015

Ostrzeżenie: (0%)
-----


witam, mam taki problem, gdy uruchamiam stronę w przeglądarce to poprawnie się generuje obrazek do pliku ale kiedy robię to przez ssh, cron to obraz się nie tworzy.
Poniżej kod strony:
  1. <html lang="pl">
  2. <head>
  3. <!-- Required meta tags -->
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6.  
  7. <!-- Bootstrap CSS -->
  8. <!--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">-->
  9.  
  10. <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
  11.  
  12. body {
  13. background-color: #171e22;
  14. margin-top:100px;
  15. color: #c2c2b6;
  16. }
  17.  
  18. .banner {
  19. background-image: url(images/bg.png);
  20. width: 1130px;
  21. height: 300px;
  22. border: 1px solid #3c3c41;
  23. text-align:center;
  24. }
  25.  
  26. .text-gradient {
  27. font-size: 20px;
  28. font-family: AdrianoOpti;
  29. font-variant: small-caps;
  30. color: #e6ddbe;
  31. background: -webkit-linear-gradient(top,#fff,#a9956f);
  32. background-clip: border-box;
  33. -webkit-background-clip: text;
  34. -webkit-text-fill-color: transparent;
  35. position: relative;
  36. display: inline-block;
  37. }
  38.  
  39. .c-panel {
  40. height: 42px;
  41. margin: 0 31px 0 33px;
  42. background: url("images/c-panel-bg.png") center no-repeat;
  43. background-size: 100% 100%;
  44. line-height: 42px;
  45. position: relative;
  46. /*left: 340px;*/
  47. /*top: 250px;*/
  48. margin:auto;
  49. width:300px;
  50.  
  51.  
  52. }
  53. .c-panel:after {
  54. width: 31px;
  55. background-image: url("images/c-panel-after.png");
  56. left: 100%;
  57. }
  58.  
  59. .c-panel:before {
  60. width: 33px;
  61. background-image: url("images/c-panel-before.png");
  62. right: 100%;
  63. }
  64.  
  65. .c-panel:after, .c-panel:before {
  66. content: '';
  67. display: block;
  68. height: 100%;
  69. /*background: center no-repeat;*/
  70. position: absolute;
  71. top: 0;
  72. }
  73.  
  74. @font-face {
  75. font-family: 'abel-regular';
  76. src: url('abel-regular.ttf');
  77. }
  78.  
  79.  
  80.  
  81. </style>
  82.  
  83. <script src="html2canvas.js"></script>
  84.  
  85. <title>Banner!</title>
  86. </head>
  87. <body>
  88.  
  89. <div class="banner" id="capture">
  90. <img src="images/logo.png" width="274" style="padding-top:5px;position:relative;margin:auto;"/>
  91.  
  92. <div class="c-panel">
  93. <span style="color: inherit;font-size:15px;font-family:abel-regular;">test</span>
  94. </div>
  95.  
  96.  
  97.  
  98.  
  99. <!--<div style="position:absolute;top:50px;">
  100. <div class="ContentTypeBadge__icon__YLW" style="background-color: rgb(30, 130, 90); background-image: url(users.png);"></div><h6 class="ContentTypeBadge__text__3Wq" style="width: 130px;"><span data-gettext-identifier="explorenew-content-type-story">Użytkowników: 69</span></h6>
  101. </div>-->
  102. </div>
  103.  
  104. html2canvas(document.querySelector("#capture")).then(canvas => {
  105. document.body.appendChild(canvas);
  106.  
  107. //Test
  108. var dataURL = canvas.toDataURL("image/png");
  109. //var dataURL = canvas.toDataURL();
  110. $.ajax({
  111. type: "POST",
  112. url: "save.php",
  113. data: {
  114. imgBase64: dataURL
  115. }
  116. }).done(function(o) {
  117. console.log('zapisano');
  118. });
  119. });
  120.  
  121. </script>
  122.  
  123.  
  124. <!-- Optional JavaScript -->
  125. <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  126. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  127.  
  128. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  129. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  130. </body>
  131. </html>
Go to the top of the page
+Quote Post
gitbejbe
post 15.02.2019, 22:19:17
Post #2





Grupa: Zarejestrowani
Postów: 515
Pomógł: 63
Dołączył: 27.08.2012

Ostrzeżenie: (0%)
-----


odpal bezpośrednio ten plik save.php - nie zapomnij o przekazaniu imgBase64 z urlem obrazka

js działą po stronie przeglądarki, dlatego nie możesz wykonać kodu js w cronie/ssh
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 13:14