Upload From Pys60 To Php Help Plz

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Upload From Pys60 To Php Help Plz

    Hia guys was wondering if anyone could help me with a php script.

    Im working on an idea for an app using pys60 at the moment an im using python to transfer files from my phone to my web server.

    Iv finally managed to get the python script to run and post files through a php script onto my server but the problem is that if i upload a file from my phone with the same name as one on the server then it overwrites the previous file on the server and i was wondering if theres a way around this by getting the php script to rename a file if it already exists or even change the file names as they upload?

    this is the php script that im using at the moment

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php
    // Copyright © 2007 LEFEVRE Damien
    // image_uploader.php implementation

    // In this example a directory "images" needs to be present on the same directory where
    // image_uploader.php is, with the necessary rights for the script to write data inside

    if(isset($_POST[&#39;fileName&#39;])){
    $filename = $_POST[&#39;fileName&#39;];
    }
    else{
    // if not: just stop here
    print "False";
    die();
    }

    if(isset($_POST[&#39;data&#39;])){
    $encodedData = $_POST[&#39;data&#39;];
    $data = base64_decode($encodedData);
    }
    else{
    // if not: just stop here
    print "False";
    die();
    }

    // full path for the image
    $filepathname = &#39;images/&#39;.$filename;

    // write the file to the server into the images directory
    $handle = fopen($filepathname, &#39;wb&#39;);
    fputs($handle, $data, strlen($data));
    fclose($handle);

    // return
    echo "True";
    ?></div>

    could anyone show me how to fix this or point me towards a couple of examples of how to rename uploads on my server. Iv not really worked with php before so any help would be much appreaciated thanks.
Working...
X