File Upload help

I didn’t write this as I have yet to find some good books on php programming that doesn’t make the wife divorce me after my last book purchases :stuck_out_tongue:

Anyway this code is claimed to be working for the person who wrote the app its in. What it does is lets me browse to the guild.xml file on my local machine then renames it randomly with a number. It fails any time I try to do it with a

[phpBB Debug] PHP Notice

: in file /roster/roster/roster-update.php on line 24: copy() [function.copy]: Filename cannot be empty
Error[phpBB Debug] PHP Notice: in file /roster/roster/roster-update.php on line 32: fopen(roster/uploads/5444guild.xml) [function.fopen]: failed to open stream: No such file or directory
could not open XML input

I simply need this dang thing to work and its driving me crazy. That snip can be rewritten as long as it allows for the next part of the script to work which is below it.

print '<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr><th>Cleanup Successful. <a href="index.php?roster">Return to Roster</a></th></tr>

} elseif (isset($_POST[‘SubmitOne’])) {
if ($_FILES[‘GuildData’][‘name’] == “guild.xml”) {
print ‘

$target_path = “roster/uploads/”;
$file_name = $_FILES[‘GuildData’][‘name’];
$path= “roster/uploads/”.$new_file_name;
if($GuildData !=none) {
if(copy($_FILES[‘GuildData’][‘tmp_name’], $path)){
print ‘’;
print ‘’;
} else {echo “Error”;}

The above fails

this is what needs to happen after the above suceeds.

	function GetElementByName ($xml, $start, $end) {global $pos; $startpos = strpos($xml, $start); if ($startpos === false) {return false;} $endpos = strpos($xml, $end); $endpos = $endpos+strlen($end); $pos = $endpos; $endpos = $endpos-$startpos; $endpos = $endpos - strlen($end); $tag = substr ($xml, $startpos, $endpos); $tag = substr ($tag, strlen($start)); return $tag;}
	$pos = 0; $Nodes = array();
	if (!($fp = fopen($path, 'r'))) {die("could not open XML input");}
	while ($getline = fread($fp, 4096)) {$data = $data . $getline;}
	$count = 0;
	$pos = 0;
	while ($node = GetElementByName($data, "<Member>", "</Member>")) {
		$Nodes[$count] = $node;
		$data = substr($data, $pos);
Success: Roster Updated
The guild.xml has been successfully uploaded, and the roster updated.
Sponsor our Newsletter | Privacy Policy | Terms of Service