Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP Upload using Uploadify

<?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.';
	}
}
?>

Open in new window


I am running xampp on a windows system
Above code:
The actual root to the uploads directory is as follows:
c:\xampp\htdocs\Development\dev\Uploadify\uploads
Or
http://localhost:888/Development\dev\Uploadify\uploads
It has the correct permissions and can be accessed via the above url

Problem:
The above page is called by the index.php page, which uses a fileuploader interface on the index page to upload files
The index page goes through the motions of file upload with no errors and the file upload indicators all show the files have been uploaded
Problem is that no files appear in the uploads folder

I think this is where the problem lies: $targetFolder = '/uploads'; // Relative to the root

Any ideas please ?
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doctorbill

ASKER

This is not relevant as other file uploaders are working
Complete
If it wasn't about limitations you could also close the question differently, It'd not bother me. I only see no other way a file doesn't arrive for move_uploaded_file() to pick it up other than wrong limitation settings or too large file.

See your closing possibilities:
http://support.experts-exchange.com/customer/en/portal/articles/2201045-what-options-do-i-have-for-closing-my-question-

Bye, Olaf.