8
I refer to this link http://blueimp.github.io/jQuery-File-Upload/. The documentation is very vague. I have already changed the "action" of the "form" but without success. Form Html5:
<form id="fileupload" action="bloco_img_upload.php" method="POST" enctype="multipart/form-data">
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<noscript><input type="hidden" name="redirect" value="bloco_img_upload.php"></noscript>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add arquivos</span>
<input type="file" name="files[]" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span>Iniciar envio</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancelar envio</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="glyphicon glyphicon-trash"></i>
<span>Excluir</span>
</button>
<input type="checkbox" class="toggle">
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-lg-5 fileupload-progress fade">
<!-- The global progress bar -->
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-success" style="width:0%;"></div>
</div>
<!-- The extended global progress state -->
<div class="progress-extended"> </div>
</div>
</div>
<!-- The table listing the files available for upload/download -->
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
</form>
bloco_img_upload.php
<?php
include("arq_pro.php");
include("../arq_fun.php");
include("redimagens.php");
$SqlMini=mysql_query("SELECT LarMinImg,AltMinImg FROM dados_config WHERE Emp=$EmpPess32 AND Bloco=$IdBloco32;");
list($LarMini,$AltMini)=mysql_fetch_row($SqlMini);
$targetFolder="imgclientes/".$EmpUrl1."/";
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
$ContNot=0;
for($i = 0; $i < count($_POST["files"]); $i++) {
if (!empty($_FILES) && $_POST['token'] == $verifyToken){
$tempFile = $_FILES['files']['tmp_name'][$i];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['files']['name'][$i];
$fileTypes = array('jpg','jpeg','gif','png');
$fileParts = pathinfo($_FILES['files']['name'][$i]);
if (in_array($fileParts['extension'],$fileTypes)) {
preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $_FILES['files']["name"][$i], $ext);
$ImgNome = md5(uniqid(time())) . "." . $ext[1];
$ImgDir = "imgclientes/".$EmpUrl1."/".$ImgNome;
move_uploaded_file($tempFile,$ImgDir);
if(!is_dir("imgclientes/$EmpUrl1/")) {
mkdir("imgclientes/$EmpUrl1", 0755);
}
if(!is_dir("imgclientes/$EmpUrl1/mini/")) {
mkdir("imgclientes/$EmpUrl1/mini", 0755);
}
$ImgDirMini = "imgclientes/".$EmpUrl1."/mini/".$ImgNome;
$DimImg=getimagesize($ImgDir);
$LarImg=$DimImg[0];
$AltImg=$DimImg[1];
if($LarImg<$AltImg){
$img = new canvas();
$img->carrega("$ImgDir")
->redimensiona( 430, 620, 'crop' )
->grava("$ImgDir");
$img = new canvas();
$img->carrega("$ImgDir")
->redimensiona( $LarMini, $AltMini, 'crop' )
->grava("$ImgDirMini");
}else{
$img = new canvas();
$img->carrega("$ImgDir")
->redimensiona( 640, 480, 'crop' )
->grava("$ImgDir");
$img = new canvas();
$img->carrega("$ImgDir")
->redimensiona( $LarMini, $AltMini, 'crop' )
->grava("$ImgDirMini");
}
mysql_query("INSERT INTO `dados_img` SET `Emp`=$EmpPess32,`Bloco`=$IdBloco32,`Vinculo`=$IdVinc32,`Img`='$ImgNome';");
} else {
echo 'Tipo de arquivo inválido.';
}
}else{
echo 'Erro de validação.';
}
$ContNot=$ContNot+1;
}
?>
This is the error shown after upload attempt: Error Not Found.
What should I change to work on my site in php?
it is easy to implement for any language !!!
– user6026
But which fields to change? Where to put the folder in which the file to be saved (in the case of php)?
– Márcio Teixeira
I made an example right below as an answer.
– user6026