Jump to content

File IDS saved as numbers. if ID 1 exists, set path to ID 2


mikk809h

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

¨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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.