Question

I made a mobile game. Every user will upload 1.xml file to my server from their game. I wanna keep all these 1.xml files. But because of being xml files' names are the same(1.xml), I can't keep all of them. Like this there is only one file on server(1.xml). How can I keep all of them? is there any opinion?

Was it helpful?

Solution

I agree with FD_ in that you might want to rethink how you are saving that data.

If you definitely need to store the xml file though you could have your game call a php file (i.e. www.mysite.com/getlastidx.php) which will look at the last number of the uploaded file and increment it by one. So for the first user to upload a file the script would return 1 and you would upload the xml file as 1.xml. The second user would hit that php script and it would return 2 (since it scans the upload directory and knows what the highest number uploaded was) and so that user would upload as 2.xml.

Does that make sense?

EDIT: Or you could just name the file a random string of numbers + the datestamp. There is a chance you might overwrite an existing file, but it's small

OTHER TIPS

My opinion is:

Don't store these xml files on your server. Implement a database on your webserver that stores whatevrer value you have to keep track of, and use eg json to communicate beteen server and app in either direction.

Solved: I used "telephone unique id". I made these xml files named as telUniqID.xml. So It works..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top