Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create temp folder, copy files to it and delete? 1

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
US
hi.
I have a page that creates a folder based on a random number that is being held in a variable. the task before me is:
1) create a temp folder on the directory where the page is. when i tried to create it, i got a message "permission denied".
2) copy files from the directory where the page is to this directory with different names. (i'm getting a message: file not found - but the file is there).
3) display the files using <img> tag. (i got a broken picture).
4) delete the temporary directory.
any suggestions?
thanks.

 
You might have a permissions problem on the directory where the web page is hosted. This often happens with databases.

From a cmd prompt on the server, type

cacls dirname /E /G guest:W

where dirname is the directory where the web page is hosted. When you access the web page as a remote user, you are coming in as the guest user. The guest user does not have write privileges so they can't do anything to the file system. By changing the ACL, you are giving the guest permission to write. If that doesn't work, change the W to F.
 

On IIS 6 and below your ASP user is "IUSR_<servername>".
On IIS 7 it is "I_USR"

You must grant that user permission to create a folder/ directory and files.
 
In that case it will probably need to be

cacls dirname /E /G everyone:F

As long as the directory is not shared publicly, it will not be a problem.
 
xwb and foxbox,
thanks for replies.
the users are remote users (public).
xwb, the directory name is a random number. how do i grant permission to a user for a random number in asp? can you please explain more?
anyway, my final goal is to keep the html code from showing the file names. the page, without the process above, would look like this:
Code:
<img src="2.gif />
<img src="7.gif />
<img src="3.gif />
<img src="9.gif />
which, as you can see, reveals the file names.
but, with the createfolder/copyfile method, i can copy the above files to fixed file names and the html code would show this:
Code:
<img src="file1.gif />
<img src="file2.gif />
<img src="file3.gif />
<img src="file4.gif />
i'm trying to create a captcha that will keep bots from running our web pages.
if you know of a captcha that will go to one page if the code is correct, and to another page if the code is incorrect, please let me know.
the captcha's that i have seen, just sit there and display on the same page "the code is incorrect" or the "code is correct", which is not really doing an "action".
thanks.
 
i would not go that way. there many simple ways to do that eg:
Ask the answer to a relative simple question "3 + 4 = ?" ("3" "+" and "4" could be generated)

Did you consider to put the gif's into a blob field in a table? Then call your image.asp with a parameter. Why do you think a bot is clever enough to guess the answer for "image.asp?i=1" ?

 
foxbox,
thank you. excellent idea. what this "bot" does, is takes the html page code, parses it and gets the values from it. i'm going to use your excellent suggestion and see if it will show up on the html code.
my question is:
1) how would i pass the result to the next page? using session variables? or ?
i'll post back shortly.
best regards.
 
my table would have 3 fields:
id - blob - answer

i call image.asp with a random number (based on the number of gif's in my table)

on the form the user must "answer" (eg type the word on the gif). yes, i store the image number in a session var.

after submitting the page, i know which GIF the user saw, and i check his/her answer with the answer in the database...
 
thanks foxbox.
when i call img.asp to display the question image, do i code like this?:
<img src="page1.asp">
then page1.asp will display the image based on the session variable, which he cannot see. but if i code like this:
<img src="page1.asp?img=1">
then he will know after a while which img is associated with what answer. am i right?
thanks.
 
mmmmm, that's a yes if "he" is a person. so img.asp should use the session var too. that's no problem with 1 image;
in the other post we encounter something strange with calling img.asp twice. i tried various things but could not solve it yet... But i presume you can make it work with that limitation.
 
thanks foxbox. your idea was excellent.
here's what i did:
1) created lots of images with questions that only humans can understand.
2) page1.asp finds a random number and passes it to cap.asp via session variable ("img_num").
3) cap.asp gets sessiona variable ("img_num") and usese image.asp to display the corresponding image using binarywrite.
4) user puts the answer in the input box in cap.asp. the form in cap.asp has action=page2.asp
5) page2.asp checks img_num with answer corresponding to the image. if correct, continues with the rest of the process. if incorrect, it ends in the first line with message "incorrect answer".
thanks so much. i've been working on this for over 3 weeks now. thanks to your excellent suggestion, it was solved today.
you deserve a star.
best regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top