Jump to content

ASP code required to create a file.


Recommended Posts

Hello,I am making a profile system for my website, and i need a file to be made in the directory "/users/" then i need the file name to be the username (the one that was registered with).So when You press "register" you will have your profile called example: www.website.com/users/"username".If somebody could tell me this code please,Thanks.Ps, In the future i need this file to have content on it already. Some some help with that will be good.

Link to post
Share on other sites

Don't make a separate file for each user, have 1 ASP page that reads which user it is, gets their info from the database, and displays it where it needs to go. Most sites do something like that. With a server running Apache you can use some tricks to still get the URL to point to a file with the user's name, but with a server running IIS and ASP I don't think you can do that.

Link to post
Share on other sites

You need to send the page the ID or username of whichever user to show information for. So the address would look like this:user.asp?id=123You read the id using Request.Querystring, and use the ID to look up the info in the database, then write it wherever you want it on the page.

Link to post
Share on other sites

Great, thanks so when you click register your username, email, password, name and now an id gets sent to the database. Am i correct?I already have afield called "userid" would that help?And how do i go about creating content on that page?Thanks,

Link to post
Share on other sites

You create content the same way you create content on any other page, the only thing special about a dynamic page like this is certain pieces of content (the page title, most notably) are coming from the database. So instead of static text in the <title> tag, you might have a Response.Write statement writing the person's name.

Link to post
Share on other sites

Ok... Do you have any idea how i could create an interface where each indvidual can edit there profile?So i have a field in the database called id how do i make that a page like id=1, id=2?

Link to post
Share on other sites

A page for people to edit the profile is just a normal page with a form on it with a text box for everything that is in the database. Submitting the form would go to a processing page that reads each of the fields and updates the database. There's nothing special you have to do to link each id to the profile page. If you make a link with a certain id on it, the page will read the id and get the data. I'm not sure what the problem is.

Link to post
Share on other sites

Save the actual file as normal in a directory you choose, and just save the filename of the file in the database. You can save the binary data in the database, but it will slow things down.

Link to post
Share on other sites

Ok thanks, so i would have an upload system which would upload the file to a directory (does this file have to be unique, different per user?) How would i also have the image url sent to the database? and show up in the profile? (same applys to the a file)Is it also possible to send the url to another table/database? or is it possible to send the image and download to another location without the need for another database?

Link to post
Share on other sites
  • 2 weeks later...

Ok , so i have worked it out that i will use a simple method of a mysql UPDATE command to edit the fields (name, occupation etc.) But the thing i still dont understand is how to save and display an avatar in your profile. Is it possible to have a field where the user can choose an image to upload and save the location and file to a directory an database and display it. If so How?The thing is i know how to do this in theory but not the coding. Thanks for your help

Link to post
Share on other sites

Check the FileSystemObject reference on the w3schools site to see how to create or copy a file. If they upload a file, you would copy the uploaded file to whatever directory you want to keep pictures in and save the name of the file with the user's record.As far as uploading goes, ASP does not have built-in support for file uploads. You would need to use a third-party component to handle the upload. The server you're on might already provide one, but if not there are free ones you can use, like freeaspupload. However, when you use an upload component it removes the Request.Form collection, you can no longer access values using Request.Form. Typically you have to access all values using the upload object. I've used freeaspupload before and it worked out pretty well, regardless of the Request object being unavailable.

Link to post
Share on other sites

would it be easier using php? the only problem with freeaspupload is that it requires permmisions set and i cant do this on a windows server and i am useing a linux one now. Im i being really dumb and does ASP work on linux?Thanks

Link to post
Share on other sites

PHP does have native support for file uploading, it is easier with PHP. ASP does not run natively on Linux, you would need to use an emulator if you want to do that. That also requires installing software on the server.But, regardless, you don't need to install or configure anything to use freeaspupload, that's why I like it. You just need to include the file which creates an upload class and use it from there. There is some documentation on how to use it at their site.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...