|
It can be uploaded to one place and then a different place next time, and then circle around to an infinite loop. In fact there are many ways to accomplish this task - which is what these questions are on about. Trying to narrow it down from 100s of choices to 1.
Believe it or not, figuring out which directory has less stuff in it might be less complex to code than going A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B, A, B and so on. The reason is because to do that, you need to know the last place you saved the file. And to do that, we need some kind of logging or a different mechanism.
If you keep a log of uploads, you can store things (that you don't seem concerned over) like the user name and IP Address. Along with this information you can store what directory the file went into. Then, after somebody uploads a file, your ASP code would check the log, pulling up the most recent entry to find what directory that file was saved to - and then write to the other directory.
Instead of writing this information to a database table, you could use a flat file. In fact you could write ONLY the name of hte last directory you used. That would take less work to code - at least at first blush. Because you've got a server app, it's possible two people could save a file at the same time, then you have locking issues with the file. So I wouldn't recommend that route.
You've already seen how you can create a variable, "hard code" it to C:\Input2 and then have everything go there. Instead, you need a more intelligent way to put the correct folder name in that variable right before you save the file. It could be by logging. It could be some other means. It could be by running a count of the files in each directory and returning the one with the least stuff in it.
I'd probably go with the last because (1) if you don't need a log this way is the least work for the most payoff and (2) if you're using 2 directories for load balancing, this will get you better balance.
|