The solution is simple, just you implement:
After uploading the file you can redirect the user to the video page and to the file that has the iframe know which video is being "prompted" you use Query String
:
<?php
include("conexao.php");
$msg = false;
if(isset($_FILES['arquivo'])){
$extensao = strtolower(substr($_FILES['arquivo']['name'], -4));
$novo_nome = md5(time()) .$extensao;
$diretorio = "animes/";
move_uploaded_file($_FILES['arquivo']['tmp_name'], $diretorio.$novo_nome);
$sql_code = "INSERT INTO arquivo (codigo, arquivo, data) VALUES (null, '$novo_nome', NOW())";
if ($mysqli->query($sql_code))
$msg = "Arquivo enviado. <a href='gerador_paginas.php?video=".$novo_nome."'>Clique aqui</a> para gerar o HTML";
else
$msg = "Falha ao enviar.";
}
?>
After that, you recover from the URL which file name to display:
<?php
$novo_nome = $_GET['video'];
$arquivo = fopen($novo_nome, "w");
$texto = "<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<title></title>
</head>
<body>
<iframe src=\"upload/animes/$novo_nome\" frameborder=\"0\"></iframe>
</body>
</html>";
fwrite($arquivo, $texto);
?>
And also you can create as a playlist, listing the videos and always redirecting to sua_pagina.php? video=NOME_DO_VIDEO
One tip I recommend is never to use names in Query String
'cause that could be a problem up front for you. It would be nice to use the ID of the record inserted in the database referring to that video, then you take the ID via Query String and do the query in Mysql to return the video name.
I didn’t understand the need only to create an html file containing iframe, because if you have many videos, you will create many files on your server. If you just want to let the user upload the video and then make this video accessible, just create a page that takes the query string and assembles the HTML without saving a new file on your server, getting more or less like this:
<?php
$novo_nome = $_GET['video'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<iframe src="upload/animes/<?php echo $novo_nome;?>" frameborder="0"></iframe>
</body>
</html>
Well I create several pages so that later I can be accessible to any user, it would be like a stream site
– Toniotti
One being dynamic would not meet your need? Look at this last code I posted, it makes you dynamic. Imagine that you have 1,000 generated files and you need to change the layout, that would be a headache for you.
– Alisson Acioli
But kind would have like to make this page that Voce put one for each video? Type on the index have a link to each video posted on the site.
– Toniotti
There would be a link to each video, but in these links what would change is only the contents of the query string, in case ? video=NOME_ARQUVO ... In this NOME_ARQUIVO you will make dynamic, pulling the entries registered in the database and put the name in place
– Alisson Acioli
I’ll try that, vlw by the tip.
– Toniotti