Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
jd447  
#1 Posted : Friday, December 30, 2011 6:39:33 AM(UTC)
jd447

Rank: Newbie

Groups: Member
Joined: 12/24/2011(UTC)
Posts: 2

Hello,

I guess i have an issue with the naming of the uploaded files.

I would like more than 1 user to be able to upload files through their iPhones. I'm using this:

Quote:
$path = realpath('./uploads/images/Gallery/latest/') . DIRECTORY_SEPARATOR;

$fileCount = $_POST["PackageCount"];

for ($i = 0; $i < $fileCount; $i++) {

if (isset($_FILES['File0_' . $i])) {

move_uploaded_file($_FILES['File0_' . $i]['tmp_name'], $path . $_POST['SourceName_' . $i]);

}

}

But it seems that the file naming is starting from the beginning for each user. (ex: uploaded file_01.jpg).

How can I make it to have an unique filename or even better to let user choose the name when the upload the file.

Many thanks,

Jean-Daniel

Dmitry.Obukhov  
#2 Posted : Tuesday, January 3, 2012 10:16:34 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Jean-Daniel,

As iPhone/iPad does not have file system, all files are uploaded with name UploadFileXX.jpg. To avoid collisions, you can add a script which will generate random number. Then you will need to add this random number to a name of files. Another way is to send cookie, e.g. with user name or any information. On server-side you will get a value of cookie, and add it to file names to distinguish files of each user.

If you have questions or problems with it, please let me know.

Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

jd447  
#3 Posted : Wednesday, January 4, 2012 12:23:45 AM(UTC)
jd447

Rank: Newbie

Groups: Member
Joined: 12/24/2011(UTC)
Posts: 2

Thanks Dimitri!

I understand your explanation and it makes a lot of sense. However, as I am more of an HTML/CSS developer, I don't really know how to put that in practice.

I understand that i have to add some code in the upload url to add the cookie.

- But will it be created automatically?

- Do I have to change also to change the "post" API?

Thanks!

Jean-Daniel

Dmitry.Obukhov  
#4 Posted : Wednesday, January 4, 2012 10:00:04 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Jean-Daniel,

I created and attached a sample based on standard application for Aurigma Up. It allows to send cookie with value which is returned by time() method:

Code:

if ($add_session_cookie) {
  $cookie1 = time();
  $params[] = 'cookies=' . "cookie1=" . $cookie1;
}

On the server side I got this value, and create a new folder with this name:

Code:

$cookie1 = $_COOKIE['cookie1'];
$absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $cookie1 . DIRECTORY_SEPARATOR ;

Actually, the best way is creating login page, where users will type their logins/passwords to get access to your site with Aurigma Up. You can keep and use logins as session variables to create folders named by login for each your user. Please download and try sample from this topic (iphone_corrected.zip).

File Attachment(s):
Samples_iPhone.zip (186kb) downloaded 20 time(s).
Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.