Blame view

backend/web/js/uploadify/uploadify.php 862 Bytes
c7f222e2   Artem   first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  <?php

  /*

  Uploadify

  Copyright (c) 2012 Reactive Apps, Ronnie Garcia

  Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 

  */

  

  // Define a destination

  $targetFolder = '/uploads'; // Relative to the root

  

  $verifyToken = md5('unique_salt' . $_POST['timestamp']);

  

  if (!empty($_FILES) && $_POST['token'] == $verifyToken) {

  	$tempFile = $_FILES['Filedata']['tmp_name'];

  	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;

  	$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

  	

  	// Validate the file type

  	$fileTypes = array('jpg','jpeg','gif','png'); // File extensions

  	$fileParts = pathinfo($_FILES['Filedata']['name']);

  	

  	if (in_array($fileParts['extension'],$fileTypes)) {

  		move_uploaded_file($tempFile,$targetFile);

  		echo '1';

  	} else {

  		echo 'Invalid file type.';

  	}

  }

  ?>