User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 456,468 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,780 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1406 | Replies: 1
Reply
Join Date: Sep 2007
Posts: 1
Reputation: illa_arm is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
illa_arm illa_arm is offline Offline
Newbie Poster

Question Allow User To Upload A Picture

  #1  
Sep 13th, 2007
what is coding to allow users to upload a picture in database?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 8
Reputation: cmannering is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
cmannering's Avatar
cmannering cmannering is offline Offline
Newbie Poster

Re: Allow User To Upload A Picture

  #2  
Sep 13th, 2007
You would create that segment of the form and then in the script which processes the date you need to have a variable which defines the target path.

Something like this for the form component:
<input type="hidden" name="userfilename" id="userfilename">
<span class="input_title">Choose a file to upload:</span>
<input name="uploadedfile" type="file" />

And then depending on what you are using to process that field you will need to specify the path and I recommend validating to make sure they can't upload certain extensions like executable which will destroy your database.

//$target_path = "uploads/";

// Where the file is going to be placed 
$target_path = 'C:/websites/uploads/'.$_FILES['uploadedfile']['name'];

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    //echo "The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
    echo "There was an error uploading the file";
    print_r($_FILES);
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 2:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC