1 Replies - 4424 Views - Last Post: 06 October 2011 - 07:56 AM

#1 Morgester  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 11

Uploading Image/File to server, renaming with random name then storing

Posted 05 October 2011 - 02:21 PM

Hi guys.

I have seen around that you can store image locations in a database.

What I am looking for is a way to upload an image/file to a server (files), rename to a random name so no more than one can be the same then store the location to a sql table/database.

I have searched high and low for this but just can't find it.

I would appreciate it to be in VB as its what I am using.

Thanks,

Morgester.

This post has been edited by Morgester: 05 October 2011 - 02:29 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Uploading Image/File to server, renaming with random name then storing

#2 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Uploading Image/File to server, renaming with random name then storing

Posted 06 October 2011 - 07:56 AM

Well it's pretty easy to do.

The first thing you need to do is allow the user to upload a file.

Add a FileUpload Control to your page. This will allow the user to browse for a file on their computer to select for uploading.

Add a button to the page called "upload"...this will submit the page to the server so that you can retrieve the file that the user chose using the FileUpload control.

In that button click event, generate a unique random name for the file and save it to some location on the server....or directly insert it into the database.

See the link for the FileUpload control because it has a lot of information on how to do this.

-Frinny
(please note that in order to upload a file to the server you must perform a full page post to the server... you cannot do this using Ajax as a partial page post back to the server)

This post has been edited by Frinavale: 06 October 2011 - 07:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1