-1
I have a question about changing FILE data.
<?php
include("conectar.php");
$id = $_GET['id'];
$sql = mysql_query("Select* From tb_trabalhador WHERE id = $id");
while($exibe = mysql_fetch_array($sql)){
$id = $exibe["id"];
$Nome = $exibe["Nome"];
$Morada = $exibe["Morada"];
$Tipo = $exibe["Tipo"];
$Email = $exibe["Email"];
$AlvaraNumero = $exibe["AlvaraNumero"];
$AlvaraValidade = $exibe["AlvaraValidade"];
$AlvaraAnexo = $exibe["AlvaraAnexo"];
?>
<form action="salvaralteracao.php" method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
Nome<input type="Varchar" name="Nome" value="<?php echo $Nome; ?>"><p>
Morada<input type="Text" name="Morada" value="<?php echo $Morada; ?>"><p>
Email<input type="text" name="Email" value="<?php echo $Email; ?>"><p>
AlvaraNumero<input type="integer" name="AlvaraNumero" value="<?php echo $AlvaraNumero; ?>"><p>
AlvaraValidade<input type="date" name="AlvaraValidade" value="<?php echo $AlvaraValidade; ?>"><p>
<input type="hidden" name="AlvaraAnexo" value="<?php echo $AlvaraAnexo; ?>"><p>
When I show it appears lots of symbols due to Attachments (PDF I put)
How to change this by showing attachment data names only?
Salvarcao alteracao.php
<?php
include("conectar.php");
$id = $_POST['id'];
$Nome = $_POST['Nome'];
$Morada = $_POST['Morada'];
$Email = $_POST['Email'];
$AlvaraNumero = $_POST["AlvaraNumero"];
$AlvaraValidade = $_POST["AlvaraValidade"];
if (isset($_FILES[AlvaraAnexo]) && $_FILES[AlvaraAnexo]["name"]!=''){
$nomeTemporario = $_FILES["AlvaraAnexo"]["tmp_name"];
$fp = fopen($nomeTemporario, 'r');
$AlvaraAnexo = fread($fp, filesize($nomeTemporario));
$AlvaraAnexo = addslashes($AlvaraAnexo);
fclose($fp); }
$AcidenteNumero = $_POST["AcidenteNumero"];
$AcidenteValidade = $_POST["AcidenteValidade"];
if (isset($_FILES[AcidenteAnexo]) && $_FILES[AcidenteAnexo]["name"]!=''){
$nomeTemporario = $_FILES["AcidenteAnexo"]["tmp_name"];
$fp = fopen($nomeTemporario, 'r');
$AcidenteAnexo = fread($fp, filesize($nomeTemporario));
$AcidenteAnexo = addslashes($AcidenteAnexo);
fclose($fp)
(...)
$sqlupdate = "Update tb_trabalhador SET Nome='$Nome',Morada='$Morada',Email='$Email', AlvaraNumero='$AlvaraNumero',AlvaraValidade='$AlvaraValidade',AlvaraAnexo='$AlvaraAnexo',Aci denteNumero='$AcidenteNumero',AcidenteValidade='$AcidenteValidade',
AcidenteAnexo='$AcidenteAnexo',SeguroNumero='$SeguroNumero',
SeguroValidade='$SeguroValidade',SeguroAnexo='$SeguroAnexo',FinancasValidade='$FinancasValidade',
FinancasAnexo='$FinancasAnexo',SocialValidade='$SocialValidade',
SocialAnexo='$SocialAnexo',RemuneracaoValidade='$RemuneracaoValidade',
RemuneracaoAnexo='$RemuneracaoAnexo',InstaladorNumero='$InstaladorNumero',
InstaladorValidade='$InstaladorValidade',InstaladorAnexo='$InstaladorAnexo',
MontadorNumero='$MontadorNumero',MontadorValidade='$MontadorValidade',
MontadorAnexo='$MontadorAnexo' where id=$id ";
mysql_query($sqlupdate) or die(mysql_error());header('Location: administrador.php');
?>
It looks like you are creating a form to allow the user to make changes to a record in your table. If so, the same will be able to exchange the document? (if not, my suggestion would be that you do not have that field hidden with the PDF binary) To update a record in the database you do not need to touch all fields, you can only touch the ones you actually want to change.
– Zuul
If the user has the possibility of exchanging the document, it could still be adjusted your form to not have that field hidden with the contents of the PDF. It all depends on the purpose that is driving you to have that field present.
– Zuul
Just as it is possible to have the other fields to change the pdf files could also change. My idea is to give chance to change all fields
– ChrisAdler