Uploading Files in Forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scottastrophik
Forum Newbie
Posts: 2
Joined: Thu Oct 14, 2004 1:52 pm

Uploading Files in Forms

Post by scottastrophik »

Sami | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Hello all. I am trying to make a form that allows users to send me files through email. I have been using a php form for my other websites that I got from boadrink where all I have to do is change a couple of things. I am finding out that there needs to be more in this form to allow uploads of files. I have no idea about php. Here is what I have in my html form tag:

Code: Select all

<form action="formmail.php" method="post" enctype="multipart/form-data" name="submission" id="submission">
Is there any scripts that allow me to get my form along with a file? I dont know anything about php.

I would greatly appreciate any help that anyone can give me. Thank you.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

After the form tag you will need to create file fields. Something like:

Code: Select all

<form action="formmail.php" method="post" enctype="multipart/form-data" name="submission" id="submission"> 

<input type="hidden" name="maxfilesize" value="5000000"> 
<input name="filename" type="file"> 
<input type="submit" value="upload file">
</form>
scottastrophik
Forum Newbie
Posts: 2
Joined: Thu Oct 14, 2004 1:52 pm

Post by scottastrophik »

Sami | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Thanks you, but it send me max file size 500000, itdoesnt seem to be working, maybe its my coding. Theres a hole form with it. :

Code: Select all

&lt;form action="formmail.php" method="post" enctype="multipart/form-data" name="submission" id="submission"&gt;
                      &lt;table width="550" border="0"&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;Name:&lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &lt;input name="name:" type="text" id="name:"&gt;
                          &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;Email:&lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &lt;input name="email:" type="text" id="email:"&gt;
                          &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;File:&lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &#1111;b]&lt;input type="hidden" name="maxfilesize" value="5000000"&gt; 
							&lt;input name="filename" type="file"&gt; 
							&lt;input type="submit" value="upload file"&gt;&#1111;/b]                          &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;Link:&lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &lt;input name="link:" type="text" id="link:" value="http://www."&gt;
                          &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;Submit to: &lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &lt;select name="select"&gt;
                              &lt;option selected&gt;Photshop Tutorials&lt;/option&gt;
                              &lt;option&gt;Photoshop Brushes&lt;/option&gt;
                              &lt;option&gt;Photshop Styles&lt;/option&gt;
                              &lt;option&gt;Photoshop Gallery&lt;/option&gt;
                              &lt;option&gt;Flash Tutorial&lt;/option&gt;
                              &lt;option&gt;Flash Gallery&lt;/option&gt;
                              &lt;option&gt;Football Helmets&lt;/option&gt;
                            &lt;/select&gt;
                          &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;Comments:&lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &lt;p&gt;
                              &lt;textarea name="textarea" cols="35" rows="5"&gt;&lt;/textarea&gt;
                            &lt;/p&gt;
                            &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                      &lt;/table&gt;
                      &lt;br&gt;
                      &lt;table width="200" border="0"&gt;
                        &lt;tr&gt;
                          &lt;td&gt;&lt;div align="left"&gt;
                            &lt;input type="submit" name="Submit" value="Submit"&gt;
                          &lt;/div&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;div align="right"&gt;
                            &lt;input name="reset" type="reset" id="reset" value="Reset"&gt;
                          &lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                      &lt;/table&gt;
                      &lt;p&gt;
                      &lt;input name="recipient" type="hidden" value="submission@scottastrophik.com"&gt;&lt;input name="subject" type="hidden" value="submission"&gt;&lt;input name="redirect" type="hidden" value="completed.htm"&gt;
                      &lt;/p&gt;
                    &lt;/form&gt;
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

Post by potsed »

firstly put the <input type="hidden" name="maxfilesize" value="5000000"> directly under the opening form tag
secondly remove the <input type="submit" value="upload file">

thirdly read the manual about $_FILES @ http://za2.php.net/variables.predefined
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

Post by potsed »

Post Reply