insert-coin/public_html/private/beam.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2018-10-09 19:39:09 -05:00
<?php
include("../../resources/config.php");
include("../../resources/library/main.php");
$file_name = $_FILES["uploadcoin"]["name"];
$file_ext = file_extension($file_name);
if (!empty($_POST["desired_filename"])) {
$file_name = $_POST["desired_filename"];
if (!file_extension($file_name)) {
2018-10-09 19:42:44 -05:00
$file_name = $file_name . "." . $file_ext;
2018-10-09 19:39:09 -05:00
}
}
$file_name = sanitize_filename($file_name);
$dest_name = $GLOBALS["file_beam_dir"] . $file_name;
$dest_file = root("public_html/" . $dest_name);
switch (true) {
case (empty($file_name) || empty($dest_name)):
redirect(make_url("result/beam.php?error=1"));
break;
2018-10-09 19:39:09 -05:00
case (file_exists($dest_file)):
redirect(make_url("result/beam.php?error=2"));
break;
2018-10-09 19:39:09 -05:00
case (move_uploaded_file($_FILES["uploadcoin"]["tmp_name"], $dest_file)
&& write_metadata($dest_file, $_POST["file_source"])):
if (in_array(file_extension($dest_file)),array("jpg","jpeg")) {
sanitize_image($dest_file);
}
2018-10-09 19:39:09 -05:00
redirect(make_url("result/beam.php?success="
. $file_name));
break;
default:
redirect(make_url("result/beam.php"));
break;
}
?>