Drag & drop upload after clicking a button

Can you help me on that too, my friend?

Thank you in advance.

Sure, but you really didn’t specify what the problem is, so I am unsure what it is I am helping you with. If it is different than your original problem, I’d also post it as a new thread on the forum.

When I drag an image, the progress bar is only satisfied when the upload is finished. Before the bar is filled according to the progress of the upload normally.

Are you dropping 1 or 2 images? I dropped a 1.5 MB image on there and the progress bar did two steps. I am also on a very fast connection so I had to use a large image to see if the progress bar was really doing its job.

You’re right, it is now normal.

Another thing I would do is display the progress bar next to the name and file size within the div messages. I tried, but failed.

Can you help me with that? Last I ask him for help.

Friends, I created a system to upload multiple images but I need to write everything in a json file instead of a database.

I need the id, the id and name of the gallery and the image file is written to the json file, but multiple objects “images” are written in the file. The data should be recorded within a single object “images”.

My script:


// Informações para conexão
$host = 'localhost';
$usuario = 'root';
$senha = '';
$banco = 'kurt';
// Realizando conexão e selecionando o banco de dados
$conn = mysql_connect($host, $usuario, $senha) or die(mysql_error());
$db = mysql_select_db($banco, $conn) or die(mysql_error());
// Definindo o charset como utf8 para evitar problemas com acentuação
$charset = mysql_set_charset('utf8');

include('class/resize-class.php');

$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);

function extensao($file_name){
$ext = explode('.', $file_name);
$ext = array_pop($ext);
return strtolower($ext);
}

function criptografa($file_name){
$ext = explode('.', $file_name);
$ext = array_pop($ext);
$nome = md5(uniqid(rand(), true)) . '.' . strtolower($ext);
return $nome;
}

if ($fn) {

$arquivo = criptografa($fn);

// AJAX call
file_put_contents(
'uploads/' . $arquivo,
file_get_contents('php://input')
);
echo "$arquivo uploaded";

$resizeObj = new resize('uploads/' . $arquivo);
$resizeObj -> resizeImage(200, 200, 'crop');
$resizeObj -> saveImage('uploads/thumb_' . $arquivo, 100);

$galeria = $_SERVER['HTTP_X_GALERIA'];







header('Content-Type: application/json;charset=utf-8');
$filename = 'test.json';


$i = 0;
$busca = array();

$busca[$i]['id'] = rand(1, 99);
$busca[$i]['galeria'] = $galeria;
$busca[$i]['imagem'] = criptografa($fn);

foreach($busca as $string)
{


$grava["imagens"] = $string;

$somecontent = json_encode($grava);

if (is_writable($filename)) {


if (!$handle = fopen($filename, 'a')) {
echo "Não foi possível abrir o arquivo ($filename)";
exit;
}


if (fwrite($handle, $somecontent) === FALSE) {
echo "Não foi possível escrever no aqruivo ($filename)";
exit;
}

echo "Sucesso. Escreveu ($somecontent) no arquivo ($filename)";

fclose($handle);

} else {
echo "Impossível escrever em $filename";
}	

}

$i++;

exit();

}

Write this in the file json (2 images):

{"imagens":[{"id":51,"galeria":"50","imagem":"43e4ff5357ccb77c28329758a56bfc92.gif"}]}{"imagens":[{"id":55,"galeria":"50","imagem":"ab8ed241aac07b57ff276e533e65a9be.png"}]} 

It is my impression or a response has been erased? = /