I am trying to play a youtube video that a user enters into a form. Specifically a user will paste a youtube video URL into my form, hit submit, and on the next page it will play that video in an iFrame. Does anyone have any idea how to do this? Somehow it needs to convert the YouTube URL (https://www.youtube.com/watch?v=VIDEO_ID) to the embed URL (http://www.youtube.com/v/VIDEO_ID) and then make that the source of the iFrame on the next page. Thanks in advance for your help!
Try this:
<?php
if(isset($_POST["youtube"]))
{
if(strlen($_POST["youtube"]) == 11)
{
$videoid= $_POST["youtube"];
echo <<< EOF
<iframe frameBorder="no" width="100%" height="100%" src="http://www.youtube.com/embed/$videoid" allowfullscreen></iframe>
EOF;
}else{
$yturl = rawurldecode($_POST["youtube"]);
parse_str( parse_url( $yturl, PHP_URL_QUERY ), $yt_array_of_vars );
$videoid= $yt_array_of_vars['v'];
echo <<< EOF
<iframe frameBorder="no" width="100%" height="100%" src="http://www.youtube.com/embed/$videoid" allowfullscreen></iframe>
EOF;
}
}else{
$posturl = htmlspecialchars($_SERVER["PHP_SELF"]);
echo <<< EOF
<html>
<head>
<style>
html,body, div, iframe{
height: 100%;
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
margin: 0; padding: 0;
}
</style>
</head>
<body>
<form method="post" action="$posturl">
<div align="center">
<p> <h3> Type the Youtube URL or VIDEOID</h3></p>
<input type="text" name="youtube" value="">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
EOF;
}
?>
Check the YouTube iframe options here
If you want the html5 player, append html5=1to the iframe src, like this:
<iframe frameBorder="no" width="100%" height="100%" src="http://www.youtube.com/embed/$videoid?html5=1" allowfullscreen></iframe>
Related
In my Angular8 app, I have a drop zone where I can drag & drop files, such as PDF, MS Word, CSV, etc. I am using the technique found on this blog, but also documented by Mozilla MDN. The code works very well, but the one important thing I can't figure out is how to capture the file bytes being uploaded, so that I can save them to the database.
I placed a screenshot of the Opera browser source debugger below, showing the typescript and resulting fileObj and blobObj values. The debugger complains about readAsBinaryString(blobObj), saying that blobObj is not a Blob. Looking at the blobObj value, I can see it's not a Blob that I've seen before. And, looking at all the values, none stand-out to me as a Blob. Also, the file bytes aren't obvious either. Looking at the html, below, I can't think of a change that would reveal the bytes.
I'm hoping someone with drag and drop experience can explain how it's done.
Thanks!
Debugger Screenshot
HTML
<table class="table table-striped table-forum">
<tbody>
<tr>
<td>
<div class="container" style="float: left; padding-top: 10px; padding-left: 10px;" appDnd (fileDropped)="onFileDropped($event)" (itemDropped)="onItemDropped($event)">
<input type="file" #fileDropRef id="fileDropRef" multiple (change)="fileBrowseHandler($event.target.files)" />
<img src="assets/img/dnd/ic-upload-file.svg" alt="">
<h3>Drag and drop file here</h3>
<h3>or</h3>
<label for="fileDropRef" style="font-size: 14px; font-weight: 600; height: 25px; padding: 5px 5px;">Browse for File</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="files-list" style="width: 35%;">
<div class="single-file" *ngFor="let file of files; let i = index">
<img src="assets/img/dnd/ic-file.svg" width="45px" alt="file">
<div class="info">
<h4 class="name">
{{ file?.name }}
</h4>
<p class="size">
{{ formatBytes(file) }}
</p>
<app-progress [progress]="file?.progress" style="width: 200px;"></app-progress>
</div>
<img src="assets/img/dnd/ic-delete-file.svg" class="delete" width="20px" alt="file" (click)="deleteFile(i)">
</div>
</div>
</td>
</tr>
</tbody>
</table>
const reader = new FileReader();
// FileReader has an onload event that you handle when it has loaded data
reader.onload = (e: any) => {
const data = e.target.result as any;
console.log({type: 'GalleryComponent prepareFilesList - data:', data});
};
// this will kick off the onload handler above
reader.readAsDataURL(file);
I am implementing Nodemailer to send emails from Node.Js. However, HTML page is not responding properly.
My index.js:
const nodemailer = require('nodemailer');
const fs = require('fs');
const handlebars = require('handlebars');
const transporter = nodemailer.createTransport({
host: "smtp.mailtrap.io",
port: 2525,
auth: {
user: "xxxx",
pass: "xxxx"
}
});
const readHTMLFile = (path, callback) => {
fs.readFile(path, {encoding: 'utf-8'}, (err, html) => {
if(err){
callback(err);
}
else{
callback(null,html);
}
});
}
readHTMLFile('index.html', (err, html) => {
const template = handlebars.compile(html);
const replacements = {
username: 'Bob'
};
const htmlToSend = template(replacements);
const message = {
from: 'testxxxx#example.com',
to: 'to#xxxx.com',
subject: 'No reply',
html: htmlToSend
}
transporter.sendMail(message, (error, info) => {
if(error){
console.log(`error: ${JSON.stringify(error)}`);
}
else{
console.log('Email sent: ' + info.response);
}
});
});
My index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Email Notification</title>
</head>
<body>
<div>
<h3>Hey! {{username}}!!</h3>
<form action="https://www.google.com">
<input type="submit" value="Go to Google" />
</form>
<h4>Go to Stackoverflow</h4>
</div>
Now, user gets email and user is able to click on Go to Stackoverflow link and gets redirected to stackoverflow website. However, when user clicks on button Go to Google, nothing happens. I want user to click on a button and get redirected to the website. Please help me to solve this issue.
The problem is that you are using a form. Some email clients do not accept forms. For a detailed explanation see https://www.sitepoint.com/forms-in-email/.
Instead, if you want a link, use an <a> like your other example.
If you want it looking like a button, for the best results (i.e. for best rendering across all different email clients), you'll need to use a table approach:
<table width="100%" style="border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0;font-family:Arial, sans-serif;color:#333333;">
<tr>
<td style="padding-top:10px;padding-bottom:10px;padding-right:0;padding-left:0;border-collapse:collapse;">
<!-- START CENTERED BUTTON -->
<center>
<table border="0" cellpadding="0" cellspacing="0" style="margin:0 auto;">
<tbody>
<tr>
<td align="center" bgcolor="#D90432" width="200" style="-moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; padding-bottom: 15px; padding-left: 15px; padding-right: 15px; padding-top: 15px; border: none; line-height:20px;color:#ffffff;">
Read more
</td>
</tr>
</tbody>
</table>
</center>
<!-- END CENTERED BUTTON -->
</td>
</tr>
</table>
I have a strange issue i cannot explain. i am using the play framework and when i try to run the View below it only works when i REPEAT the form action below... it works but i know it's not right. appreciative if anyone can help explain or correct.
#(errorMessage: String = "")(implicit messages: Messages)
#helper.form(routes.ApplicationHomeController.login) {
#main(title = messages("single.title")) {
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="userbox">
<form action="#{routes.ApplicationController.doLogin()}" method="post"></form>
<form action="#{routes.ApplicationController.doLogin()}" method="post">
<div style="color: red">#errorMessage</div>
<h1 id="logintxt" style="background-color: rgb(11, 146, 9);
background-position: initial;
background-repeat: initial;">Driver Service <b>ß</b>eta</h1>
<div id="submit_giff" style="display: none;">
<hi> Authenticating: <img src="/assets/images/loader-bar.gif" align="absmiddle"> </hi>
</div>
<input id="name" name="userName" placeholder="Username" style="opacity: 1;
background-color: rgb(255, 255, 255);
background-position: initial;
background-repeat: initial;">
<input id="pass" name="password" type="password" placeholder="Password" style="opacity: 1;
background-color: rgb(255, 255, 255);
background-position: initial;
background-repeat: initial;">
<p id="namealert" style="display: none;
opacity: 1;">Username:</p>
<p id="passal" style="display: none;
opacity: 1;">Password:</p>
<input id="loginbtn" style="opacity: 0.2;
cursor: default;" type="submit" value="Login">
</form>
</div>
<script src="/assets/javascripts/login.js"></script>
}
}
Two immediate observations.
One: #helper.form(...) will write a <form> element into the HTML that ultimately gets generated. Your view then includes other literal <form>s nested inside the first form. Nested forms are invalid HTML. You have one form submitting to routes.ApplicationController.doLogin and the other submitting to routes.ApplicationController.login. Who knows which of these the browser will actually submit to? We can't really predict because nested forms are invalid.
Two: you have your #main(...) view nested inside your #helper.form(...). I assume your main view contains <html>...</html>. This is going to result in HTML that starts with a <form> element, inside which is the <html> element. This is horribly invalid markup too.
My guess is one or both of these issues are your problem.
Try taking your generated HTML and running it through an HTML validator like https://validator.nu/. Fix any issues the validator finds, don't nest forms, and decide which (single) route the login form should actually submit to.
I have a form like this:
<form method="post" enctype="multipart-form-data" name="my_form" action="http://www.sms-online.web.id/kirim" >
<input class="field text small" type="text" maxlength="20" name="Phonenumbers" />
<br />
<textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text ></textarea>
<br />
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</form>
Let's say that form is located at http://myurl.com/form How do I post to that form and then click the submit button? and what my file should look like? should it look like this or not:
Phonenumbers=08111111
Text=SMScontent
I already tried this but didn't work:
curl --data "Phonenumbers=0811111&text=testing&TOMBOL=KIRIM" http://myurl.com/form
I tried #sputnick suggestion but got the following error:
<!DOCTYPE html>
<html style="height:100%">
<head><title> 301 Moved Permanently
</title></head>
<body style="color: #444; margin:0;font: normal 14px/20px Arial, Helvetica, sans-serif; height:100%; background-color: #fff;">
<div style="height:auto; min-height:100%; "> <div style="text-align: center; width:800px; margin-left: -400px; position:absolute; top: 30%; left:50%;">
<h1 style="margin:0; font-size:150px; line-height:150px; font-weight:bold;">301</h1>
<h2 style="margin-top:20px;font-size: 30px;">Moved Permanently
</h2>
<p>The document has been permanently moved.</p>
</div></div><div style="color:#f0f0f0; font-size:12px;margin:auto;padding:0px 30px 0px 30px;position:relative;clear:both;height:100px;margin-top:-101px;background-color:#474747;border-top: 1px solid rgba(0,0,0,0.15);box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;">
<br>Proudly powered by <a style="color:#fff;" href="http://www.litespeedtech.com/error-page">LiteSpeed Web Server</a><p>Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.</p></div></body></html>
You have a typo in the Text field (need to capitalize) so :
curl -d "Phonenumbers=0811111&Text=testing&TOMBOL=KIRIM" http://myurl.com/form
# ^
and to do such things, use cookies and a fake user-agent. Check
man curl
Use the -F flag to POST multipart-form-data as in:
curl -F "Phonenumbers=0811111&Text=testing&TOMBOL=KIRIM" http://myurl.com/form
You can use
curl--data "dob=2018&press=OK" http://blog.eduguru.in/testapp.cgi
I wan to show an overlay programmatically. I tried to modify the code in this example Opening overlays programmatically. Instead of loading the overlay only once upon document load as shown in this example, I want to show the overlay everytome a user clicks the button. The problem is thatthe overlay is loaded only for the first click. It does not open for the subsequent clicks on the same button
Here is my code.
<html>
<head>
<title>jQuery Tools standalone demo</title>
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://static.flowplayer.org/tools/css/standalone.css"/>
<style>
#facebox {
display:none;
width:400px;
border:10px solid #666;
border:10px solid rgba(82, 82, 82, 0.698);
-moz-border-radius:8px;
-webkit-border-radius:8px;
}
#facebox div {
padding:10px;
border:1px solid #3B5998;
background-color:#fff;
font-family:"lucida grande",tahoma,verdana,arial,sans-serif
}
#facebox h2 {
margin:-11px;
margin-bottom:0px;
color:#fff;
background-color:#6D84B4;
padding:5px 10px;
border:1px solid #3B5998;
font-size:20px;
}
</style>
<script>
var overlayDiv=function(){
$("#facebox").overlay({
api: true,
top: 260,
mask: {
color: '#fff',
loadSpeed: 200,
opacity: 0.5
},
closeOnClick: false,
load: true
})
};
$(document).ready(function() {
$("#triggerBtn").click(function(){
console.log(" I have been CLICKED");
overlayDiv();
});
});
</script>
<body>
<button id="triggerBtn"> Trigger Overlay</button>
<div id="facebox">
<div>
<h2>Facebox</h2>
<p>
This dialog is opened programmatically when the page loads. There is no need for a trigger element.
</p>
<form>
<input type="file" />
</form>
<p style="color:#666">
To close, click the Close button or hit the ESC key.
</p>
<p>
<button class="close"> Close </button>
</p>
</div>
</div>
</body>
This should do the trick for you.
$("#triggerBtn").click(function(){
console.log(" I have been CLICKED");
$('#facebox').data('overlay').load();
});
More information here - Jquery Tools Overlay Scripting API
This is working for me... I found this method on the jQuery Tools forum and seems to be the best I can find for now.
<script>
function popup() {
if ($("#facebox").hasClass("init")) {
$("#facebox").overlay().load();
}
else {
$("#facebox").addClass("init");
$("#facebox").overlay({
// custom top position
top: 260,
mask: { color: '#838383',
loadSpeed: 200,
opacity: 0.5
},
closeOnClick: true,
load: true
});
}
}
</script>
Simplify:
var overlay;
function overlayDiv()
{
if (typeof overlay === 'undefined')
overlay = $('#facebox').data('overlay').load();
else
overlay.load();
}
You should use:
$(".overlay").remove();