My problem is a PHP & XML problem, i work with a friend on a image upload api, and we have a problem by creating the XML string.
image.php:
$simage = new SimpleImage();
$xml = new SimpleXMLElement('<bb-upload></bb-upload>');
if($key == get_key()){
require 'upload.php';
}
else{
$xml->addChild('error', "102 Fehlerhafter Zugriffs Key");
}
header("Content-type:text/xml;charset=utf-8");
echo $xml->asXML();
upload.php:
if ($_FILES["image"]["error"] > 0) {
$xml->addChild('error', "101 Bilder fehler: " . $_FILES["image"]["error"]);
}
else{
$data = array(
'tmp' => $_FILES["image"]["tmp_name"],
'save' => time().'-'.rand(1, 1000).'.jpg',
);
$filename = $data['save'];
$simage->load($data['tmp']);
$simage->resize(350,300);
$simage->save("../data/$filename");
$xml->addChild('error', "0");
$xml->addChild('src', "http://*******.de/bb-image/data/$filename");
}
the problem is if we connect on the XML all is okay but if we upload a image, we become this error: error on line 1 at column 6: XML declaration allowed only at the start of the document
and the output like this:
?<?xml version="1.0"?>
<bb-upload><error>0</error><src>http://*****.de/bb-image/data/1355858033-712.jpg</src> </bb-upload>
why is a ? in the code !!