Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou com esse comando mais ele não faz upload dos arquivos, pra mim acho que ele não esta executando o comando PHP
o que sera que esta ocorrendo que não estou encontrando o erro ???
SISTEMA DE DOWNLOAD E UPLOAD DE ARQUIVOS -
index.php
<?php
require_once("zipar.class.php");
require_once("bd.php");
?>
<html>
<body>
<?php
if(isset($_POST['botao'])){
$arq = $_FILES['arquivo']['name'];
$arq = str_replace("","_",$arq);
$arq = str_replace("Ç","C",$arq);
if(file_exists("arquivos/$arq")){
$a = 1;
while(file_exists("arquivos/[$a]$arq")){
$a++;
}
$arq = "[".$a."]".$arq;
}
if(move_uploaded_file($_FILES['arquivo']['tmp_name'], "arquivos/".$arq)){
$zip = new Zipar();
$zip->ziparArquivo($arq, $arq.".zip","arquivos/");
unlink("arquivos/$arq");
$sqlInto = "Insert into arquivos(nome) values(:nome)";
try{
$into = $db->prepare($sqlInto);
$into->bindValue(":nome",$arq.".zip",PDO::PARAM_STR);
if($into->execute()){
echo '<div class="res">Upload com sucesso<span>X</span></div>';
}
}catch(PDOException $e){
echo $e->getMessage();
}
}
else
{
echo '<div class="res">Upload erro<span>X</span></div>';
}
}
?>
<form action="" enctype="multipart/form-data" name="upload" method="post">
<div id="nome_arquivo">
<span class="nome_arquivo"></span>
<span> <img src="img/cam.png" width="40" /></span>
<input type="file" name="arquivo" />
</div>
<input type="submit" name=botao" value="Enviar" />
</form>
<table cellpadding="3" cellpacing="0" border="0">
<thead>
<tr>
<td width="30">ID</td>
<td width="200">Nome</td>
<td width="130">Download</td>
</tr>
</thead>
<tbody>
<tr>
<?php
$sqlReady = "select * from arquivos";
try{
$ready = $db->prepare($sqlReady);
$ready->execute();
}catch(PDOException $e){
echo $e->getMessage();
}
while($rs = $ready->fetch(PDO::FETCH_OBJ)){
?>
<tr>
<td><?php echo $rs->id ?></td>
<td><?php echo $rs->nome?></td>
<td><a href="<?php echo $rs->nome ?>">Download</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>
zipar.class.php
<?php
class Zipar{
function ziparArquivos($arquivo, $nomeZip, $caminho){
$zip = new ZipArchive();
if($zip->open("arquivos/".$nomeZip, ZIPARCHIVE::CREATE) != TRUE){
return false;
}
$zip->addFile($caminho.$arquivo,$arquivo);
$zip->close();
return true;
}
}
?>
bd.php
<?php
try{
$db = new PDO("mysql:dbname=up_down; host=localhost; charset=utf8","root","");
}catch(PDOExceotion $e){
echo $e->getMessage();
}
?>Carregando comentários...