views:

29

answers:

2

So I bought this image uploader program called q-imageuploader.The company doesn't help at all with scripts to let you know a file was uploaded and the index file that is created is rewritten every time a file is uploaded.

I want to and/or make an email script that will let me know that a file has been uploaded, or modify the existing one so that instead of being re-written the index is added to. Here is the code the uploader generated for me to place in my root.

<?xml version="1.0"?>
<uploader>
<view type="thumbnails" thumbsize="115"/>
<view type="details" sizeColumnWidth="70" nameColumnWidth="130" nameColumnLabel="file" sizeColumnLabel="size"/>
<fileFilter description="Photos and images (*.jpg, *.jpeg, *.gif, *.png)" extension="*.jpg; *.jpeg; *.gif; *.png"/>
<photo_limit number="40" caption="You reached photos limit:"/>
<resize process="true" compression="100" maxWidth="1200" maxHeight="1200" generate_thumbs="true" thumbs_max_size="120"/>
<upload preload="Preloading images:" upload="Uploading images to server:" prepare="Processing and image compression:" of="of" cancel="Cancel" start="Start" warning_empty_required_field="Warning! One of the required fields is empty!" confirm="Will be uploaded:"/>
<urls urlToUpload="upload.php?" urlOnUploadSuccess="http://www.~.com/checkout.html" urlOnUploadFail="http://www.~.com/tryagain.html" urlUpdateFlashPlayer="http://www.~.com/flashalternative.html" useMessageBoxesAfterUpload="false" messageOnUploadSuccess="Images were successfully uploaded!" messageOnUploadFail="Error! Images failed to upload!" jsFunctionNameOnUpload=""/>
<watermark for_thumb="" for_image=""/>
<intro enabled="true">
    <control type="addPhotosButton" x="400" y="270" width="160" height="33" label="Add Photos for Baublet"/>
    <control type="Image" x="18" y="80" path="image_uploader_data/uploaderinstructions.png"/>
    <control type="Image" x="10" y="10" path=""/>
    <control type="Image" x="380" y="68" path="image_uploader_data/Sample1uploader.png"/>
</intro>
<main>
    <switcher thumbsLabel="thumbnails" detailsLabel="details" backgroundAlphaNormal="30" backgroundAlphaActive="68" backgroundColor="0xEAEAEA" x="500" y="10"/>
    <control type="textField" x="10" y="350" width="100" height="22">&lt;b&gt;Photo title:&lt;/b&gt;</control>
    <control type="TextInput" x="92" y="350" width="240" height="22" initValue="Your Last Name Goes Here" id="PHOTO_TITLE" label="title" isGlobal="true" showInDetailedView="true" detailed_width="250" isRequired="false"/>
    <control type="textField" x="10" y="385" width="100" height="22">&lt;b&gt;Description:&lt;/b&gt;</control>
    <control type="TextInput" x="92" y="385" width="240" height="22" initValue="Last name of Recipeint" id="PHOTO_DESCR" label="" isGlobal="true" showInDetailedView="false"/>
    <control type="textField" x="355" y="335" width="130" height="22">&lt;b&gt;Set privacy:&lt;/b&gt;</control>
    <control type="RadioGroup" x="352" y="360" id="PHOTO_VISIBILITY" label="visibility" defaultValue="0" gap="-1" isGlobal="true" showInDetailedView="true" detailed_width="75" width="150" height="22">
        <item label="public" value="0"/>
        <item label="friends only" value="1"/>
        <item label="for me only" value="2"/>
    </control>
    <control type="addPhotosButton" x="465" y="340" width="160" height="33" label="Add Additional Photos"/>
    <control type="uploadButton" x="465" y="380" width="160" height="33" label="Start upload"/>
</main>
</uploader>

I need to be able to grab the control type PHOTOID & PHOTODESCR=... and get those into an e-mail or something that will notify me.

is php needed to get this data into emailable form?

Thanks,

Michael.

(p.s) I hate it when I buy something only to find 1/2 a product.

HERE is the upload.php:

<?php

$destination_dir = "uploaded/";
$targetPath = dirname($_SERVER['SCRIPT_URI']) . "/";

$html_start = "
<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">

<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<title>Upload results</title>
</head>
<body>
";

$html_end = "
</body>
</html>
";

// Check if there are AdditionalStringVariable
$result = "AdditionalStringVariable: " . $_POST["AdditionalStringVariable"];
$result .= "<br>";


// Process value of QIU_thumbnails_Imagedata field, this is JPEG-files array of     generated thumbnails
if($_FILES[QIU_thumbnails_Imagedata])
{
foreach ($_FILES[QIU_thumbnails_Imagedata][name] as $key => $value) 
{
    $uploadfile = $destination_dir . basename($_FILES[QIU_thumbnails_Imagedata][name][$key]);


    if (move_uploaded_file($_FILES['QIU_thumbnails_Imagedata']['tmp_name'][$key], $uploadfile)) 
    {

        $big_image_name = $_FILES[Imagedata][name][$key];

        $result .= "<a href='" .$big_image_name. "'>" . "<img border = '0' src='".$value . "'/></a><br><br>";
    }
}
}
//
$result .= "<br>";


// Process value of Imagedata field, this is JPEG-files array

foreach ($_FILES[Imagedata][name] as $key => $value) 
{
$uploadfile = $destination_dir . basename($_FILES[Imagedata][name][$key]);

if (move_uploaded_file($_FILES['Imagedata']['tmp_name'][$key], $uploadfile)) 
{
    $result .= "File uploaded: <a href='".  $value . "'>" . $value . "</a><br>";
}
}


//
$result .= "<br>";




//
// Process  GlobalControlData field, this is the array of serialized data for Global controls 
// the value for each control is: id|value
    if($_POST[GlobalControlData])
    {
foreach ($_POST[GlobalControlData] as $key => $value) 
{
    $globalControlExploded =  explode("|", $value);
    $result .= "\n" . "GlobalControlData:\n\t" . $globalControlExploded[0] ."\t:\t" . $globalControlExploded[1] . "<br>";
}
}

//
// Process LocalControlData  field, this is the array of serialized data for Local controls 
// value for each image is: image||id1|value1^id2|value2^id3|value3, where image - is picture name, id - is unique control ID , and a value - control value
if($_POST[LocalControlData])
    {
foreach ($_POST[LocalControlData] as $key => $value) 
{
    $exploded = explode("||", $value);
    $parentFile = $exploded[0];

    $result .= "<br>" . $exploded[0] . "<br>";

    $explodedToControls = explode("^", $exploded[1]);

    foreach ($explodedToControls as $cnt => $val) 
    {
        $eachControl = explode("|", $val);
        $result .= "\tcontrol:\t" . $eachControl[0] . ", value:\t" . $eachControl[1] . "<br>";

    }
    //
}
}
//

$result = $html_start . $result . $html_end;

//
if(@$fp = fopen($destination_dir.'index.html', 'w')) {
  fwrite($fp, $result);
  fclose($fp);
}

echo $targetPath . $destination_dir;

?>
A: 

I presume from the XML script (it is specific to your script btw) that it will send a POST request to upload.php with the file. You will have to modify this file.

There should be a point in the file where it tries to redirect you to that "urlOnUploadSuccess" URL (which is probably passed as a parameter to upload.php). This is the point in the code where you know the upload succeeded, and you can make a simple PHP thing to send an email from there.

waitinforatrain
So I just added the upload.php file, I have two questions, The upload php file above is only generating the index.html file and the uplaod is complete. I right now the upload php is not generating the input that was given in the form to start with, how would I change that to make sure the data gets passed to the php? Thanks alot
Michael Robinson
A: 

Hi Michael,

My comment was too long to fit in a reply and since you've added the upload.php I think it's ok to submit another answer.

There's obviously more going on before it gets to upload.php.

Looking at the code, I would guess that PHOTOID & PHOTODESCR are serialised (i.e. all the parameters side by side in a string) in either _POST['GlobalControlData'] or $_POST['LocalControlData'].

Print out that $exploded array and see if the parameters you're looking for are in it.

This isn't a great script to be honest, it doesn't check for errors or check that it's actually an image (big security risk, someone could upload an exe file or a php file and really mess your site up). Check out this PEAR module instead: http://pear.php.net/package/HTTP_Upload . PEAR modules are compiled PHP so they're fast. They've had a few people working on them so they're more reliable and secure too.

waitinforatrain
Wow. I'll send the developer your feedback about security. That's pretty screwed up. Thanks.
Michael Robinson