<input type="file" name="file" multiple>
<?php
include_once('functions.php')
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" multiple>
<div class="form_submit">
<div class="form-field form-field_size_m form-field_theme_alfa-on-color" data-reactid="80">
<div class="form-field__control" data-reactid="81">
<div class="button-case" data-reactid="82">
<br>
<input class="button button_view_default button_size_l button_width_available button_theme_alfa-on-color" type="submit" value="Загрузить фотографии">
<input class="form-control" name="login" type="hidden" id="login" value="submit" />
</div>
</div>
</div>
</div>
<?php
// если была произведена отправка формы
if(isset($_FILES['file'])) {
// проверяем, можно ли загружать изображение
$check = can_upload($_FILES['file']);
if($check === true){
// загружаем изображение на сервер
make_upload($_FILES['file']);
echo "<strong>Фотографии успешно загружены!</strong>";
}
else{
// выводим сообщение об ошибке
echo "<strong>$check</strong>";
}
}
?>
</form>
using CefSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Moscow
{
public class DownloadHandler : IDownloadHandler
{
private System.Windows.Forms.ProgressBar _bar;
public string filename = "";
public DownloadHandler(ProgressBar bar)
{
_bar = bar;
}
public event EventHandler<DownloadItem> OnBeforeDownloadFired;
public event EventHandler<DownloadItem> OnDownloadUpdatedFired;
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
OnBeforeDownloadFired?.Invoke(this, downloadItem);
if (!callback.IsDisposed)
{
using (callback)
{
callback.Continue(downloadItem.SuggestedFileName, showDialog: false);
}
// Console.WriteLine(downloadItem.SuggestedFileName);
filename = downloadItem.SuggestedFileName;
//System.Diagnostics.Process.Start(downloadItem.SuggestedFileName);
}
}
/* public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
{
OnDownloadUpdatedFired?.Invoke(this, downloadItem);
}*/
public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
{
this._bar.Invoke(new Action(() =>
{
_bar.Visible = true;
_bar.Maximum = (int)downloadItem.TotalBytes;
_bar.Value = (int)downloadItem.ReceivedBytes;
}));
if (downloadItem.IsComplete)
{
this._bar.Invoke(new Action(() =>
{
_bar.Visible = false;
}));
try
{
foreach (var filename in filenames)
if (Path.GetExtension(filename) == ".exe")
System.Diagnostics.Process.Start(filename);
}
catch (System.InvalidOperationException se)
{
Console.WriteLine(se.ToString());
System.Threading.Thread.Sleep(1000);
// Console.WriteLine(System.IO.Path.GetFileName(downloadItem.SuggestedFileName));
}
}
}
}
}