mikk809h Posted May 21, 2014 Share Posted May 21, 2014 Hello Pros... Im trying to create an upload formular, where i can post data and an auth key, to upload files into a folder But i dont know how to make the path different if the path ID already exists... For example: If FILE_1 ( a folder ) exists, then create FILE_2 ( another folder ) instead. How is this possible to do?? Thanks in Advance Quote Link to comment https://forums.phpfreaks.com/topic/288660-file-ids-saved-as-numbers-if-id-1-exists-set-path-to-id-2/ Share on other sites More sharing options...
Psycho Posted May 21, 2014 Share Posted May 21, 2014 Your request is not very clear. What is the "post data" and the "auth key" and how are they related to the upload process? From your example, it appears you are wanting to check if the file being uploaded already exists in the target folder and, if so, upload the file to a different folder. But, really that is only a guess because I really don't understand most of what you posted. Quote Link to comment https://forums.phpfreaks.com/topic/288660-file-ids-saved-as-numbers-if-id-1-exists-set-path-to-id-2/#findComment-1480360 Share on other sites More sharing options...
mikk809h Posted May 22, 2014 Author Share Posted May 22, 2014 ¨Well Yeah, Sorry for my post being a bit confusing. Im going to explain it again as good as i can. What I need is a "upload.php" file, where i can post http://mysite.com/upload.php?auth=somekey&method=startSession&postdata=&fileName= ... Whenever i post that into the upload.php file, it has to create a new session. ( a new folder with session ID ). Then after the session has begun, I post (multiple) posts, with postdata. Like this: http://mysite.com/upload.php?auth=somekey&method=inSession&postdata=somefilePosted&fileName=testFile Then it creates a file with the fileName, and the postdata inside. After all posts have been completed, im going to post another method http://mysite.com/upload.php?auth=somekey&method=endSession&postdata=&fileName= After all this, the following files've been created ( for my example ) uploadFolder | SessionID | | FileName V V V uploads/1/testFile Then inside the testFile: somefilePosted Im sorry for my bad english, and i hope you understand the most of this, so you can help me out Thanks in Advance Quote Link to comment https://forums.phpfreaks.com/topic/288660-file-ids-saved-as-numbers-if-id-1-exists-set-path-to-id-2/#findComment-1480429 Share on other sites More sharing options...
Psycho Posted May 22, 2014 Share Posted May 22, 2014 Sorry, no. That really isn't any more clear. You seem to be asking about a lot of different things and I'm really not sure what the problem is that you are trying to solve via this post. I have a feeling you are making something overly complicated. Anyway, here are some 'ideas' based upon what you have stated above. Creating a new session: You have a variable for method that will tell you when to start a new session. To start a new session you can use session_regenerate_id() to create a new session ID. Then use session_id() to get the id for that session. You can then use that to create the folder. Note: You should probably go ahead and have session_start() on the page by default. That means a session will be automatically created even before you detect the 'startSession' - that session would just get thrown away and unused. Then, whenever you need to save a file, use the session id to dynamically determine the folder path. However, I'm not sure, but I think you might run into problems trying to submit files using the GET method. I would suggest using POST. Quote Link to comment https://forums.phpfreaks.com/topic/288660-file-ids-saved-as-numbers-if-id-1-exists-set-path-to-id-2/#findComment-1480442 Share on other sites More sharing options...
mikk809h Posted May 22, 2014 Author Share Posted May 22, 2014 Hmm.. Yeah.. I might look into that. Thanks for your help. Im going to respond, if i get into further trouble Quote Link to comment https://forums.phpfreaks.com/topic/288660-file-ids-saved-as-numbers-if-id-1-exists-set-path-to-id-2/#findComment-1480449 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.