Upload From Pys60 To Php Help Plz

Started on the old forum in January 2008 · view the original in the archive · old links redirect here

No replies · 602 views · started 18 years ago · 1 min read

Madmak #1

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

CODE<?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['fileName'])){ $filename = $_POST['fileName']; } else{ // if not: just stop here print "False"; die(); }

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

// full path for the image $filepathname = 'images/'.$filename;

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

// return echo "True"; ?>

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.

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close