XML Parsing & Filenames
Posted: Mon May 18, 2009 6:24 am
Hey guys I had some questions last week about using simpleXML to parse XML data. Now I want to do something similiar for image uploads. Basically I want to upload images via a flash uploader (http://www.uploadify.com/) and output file names to an XML file.
Here is what I have so far:
I am trying to create a string for each filename and then write those names directly to an XML file that already exists on the server. Besides any basic permissions problems can anyone see any reason why this wouldn't work?
Here is what I have so far:
Code: Select all
<?php
// JQuery File Upload Plugin v1.4.1 by RonnieSan - (C)2009 Ronnie Garcia
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
move_uploaded_file($tempFile,$targetFile);
}
echo '1';
foreach($_FILES['Filedata']['name'] as $str;)
{
$fp = fopen('upload.xml', 'w');
fwrite($fp, $str);
fclose($fp);
header("Location: http://mydomain.com/imgUpload/");
}
?>