To choose and upload a file without using HEScript code you can do as follow:
> <head>
> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
> <style>
> input[type="file"]{
> color: transparent;
> }
> </style>
> </head>
> <html>
> <body>
> <script>
> $(function () {
> $('input[type="file"]').change(function () {
> if ($(this).val() != "") {
> $(this).css('color', '#333');
> }else{
> $(this).css('color', 'transparent');
> }
> });
> })
> </script>
> <form action="" method="post" enctype="multipart/form-data">
> Select image to upload:<br>
> <input name="fileToUpload" type="file"/><br>
> <input type="submit" value="Upload Image" name="submit">
> </form>
> </body>
> </html>
<?php
ob_start();
define('ROOT', exo_getglobalvariable('HEPHPDataPath', ''));
define('ROOT_URL', str_replace('index.php', '', "ghe://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']));
if(isset($_FILES["fileToUpload"]["name"])){
$target_dir = ROOT."uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
if(!file_exists($target_file)){
$file = file_put_contents($target_file, FILE_USE_INCLUDE_PATH);
} else {
echo "File allready exist";
}
}
?>