Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 25th, 2005, 10:29 AM   #1
coldblue
Newbie
 
Join Date: May 2005
Posts: 20
Rep Power: 0 coldblue is on a distinguished road
upload then be shown on html page

hi

i wanted to know if there is a way i could set up some like this

a form with this

name:
password:
image: browse
email:
submit

and when they click submit it will get sent to my server and end up on a page so everyone can see it and will look something like this


image name:
email:

would you be the best if you can help me out

Aaron
coldblue is offline   Reply With Quote
Old Jun 25th, 2005, 10:42 AM   #2
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
you need to use a server side language... have the HTML form post to a PHP page like this:

HTML:
<form enctype="multipart/form-data" action="submit.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<table>
	<tr>
		<td>Name: </td>
		<td><input type="text" name="name"></td>
		<td>Password: </td>
		<td><input type="password" name="passwd"></td>
		<td>File: </td>
		<td><input type="file" name="userfile"></td>
		<td>email: </td>
		<td><input type="text" name="email"></td>
	</tr>
</table>
<input name="action" type="submit" value="Submit">
</form>

PHP: (upload code)
$uploadDir = 'uploads/';
$filename=trim($_FILES['userfile']['name']);
$uploadFile = $uploadDir . $filename;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)) {	
	print "file was successfully uploaded. <br />";
}
else {
	print "Upload failed!  Here's some debugging info: \n";
	print_r($_FILES);	
}

and if you are going to do anything with the other fields you should think about using a MySQL database. go to http://www.php.net/mysql for some more info on that.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jun 25th, 2005, 10:50 AM   #3
coldblue
Newbie
 
Join Date: May 2005
Posts: 20
Rep Power: 0 coldblue is on a distinguished road
umm i'm abit confused sorry so how does it like get on the html page ?? i know about the uploading but ?????????????????? agh soz
coldblue is offline   Reply With Quote
Old Jun 25th, 2005, 12:24 PM   #4
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Quote:
Originally Posted by coldblue
umm i'm abit confused sorry so how does it like get on the html page ?? i know about the uploading but ?????????????????? agh soz
the way I would do this is using a MySQL database. When the user submits the initial form, you upload the file and dump his/her name, pass, the filename, and email into a table. Then you would have a display page that would run a SELECT on that table and loop through each row returned and print the tags for displaying the username and image (using the name and filename fields as values). Just modify your select statement to fit your needs (e.g. only show images by user X, show all users...)

I will get you a code snippet eventually if you get stuck.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jun 26th, 2005, 5:50 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
If you are going to attempt something like this, you REALLY need to do some basic research on how the typical client/server relationship works. I say this because Skuinder's posts are apparently greek to you.

When the user types an address into the browser and clicks go, the address is resolved, a connection is established with the correct server, and the server responds to the request. If the request is for a static, informational page, the server sends that and closes the connection. If the request is for a dynamic (executable) page, the server executes the code on the requested page. That page typically generates HTML information, sends it to the browser to be rendered, and closes the connection. The processing which results in generating the information to be rendered on the client's system may interact with any number of things, including files and databases on the server system. Because the typical interaction is a connect - request - response - disconnect sequence, there is no real interaction between the client and server on anything approaching a realtime basis. In other words, don't think that mouse clicks, etc., on the browser are being monitored by the program running on the server. Once you have familiarized yourself with the basics and with one of a number of languages suitable for use on the server, you will find that you are ready to consider something like MySQL as an adjunct to your application. It isn't all that difficult to come up to speed on. You MUST understand your environment, and you MUST understand how you are going to design your application. Pursuing ANY language, or ANY set of tools is premature until you have done that.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:12 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC