FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How to upload a file via html-form and php?





TomS
Hi everybody.

Can anybody tell me how I can upload a file on my Server via PHP????
HTML-File:
Code:
<form action=upload.php method=post>
<input type=file id="upload">


PHP-File:
Code:
<?php
$file2upload=%_POST["upload"];
 //Here the code to write the file on my server...
?>


Thanks for every answer.
NG
www.zymic.com go to there tutorials in php they have a good upload script but you need to change the permissions and wot files they can upload Very Happy
TomS
Thanks for your answer. It helped very much.
Here the exact link: http://www.zymic.com/view_tutorial.php?id=85

CU
NG
np dude but make sure to edit the upload permissions because people can upload all kinds of files even .bat so just be carfull Smile
jayzee
Code:
<?php
echo "This script will upload the files in the same directory where it has been uploaded, the directory must be chmod777.<BR>";
$max="9999999";    //Maximum filesize in bytes
if($action=="doupload") {
$picture = "fileupload"."_name";
$file1 = $$picture;
$file2 = "fileupload";
$file3 = $$file2;
if($file3 != "none"){
$filesizebtyes = filesize($file3);
if(file_exists("$file3")&& $filesizebtyes <= "$max") {
copy ($file3, "$file1");
echo "File $file1 has been uploaded<BR>";
} elseif($filesizebtyes <= "$max") {
copy ($file3, "$file1");
echo "File $file1 has been uploaded<BR>";
}else{
echo "Filesize is greater than $max bytes.";
}
}
}
echo "<FONT SIZE=3 face=arial COLOR=#00000>Smart PHP Uploader</FONT>";
echo"<form  ENCTYPE=multipart/form-data method=post action=?action=doupload><input type=file name=fileupload><input type=submit value=Upload></form>";
?> 
Related topics
PHP Tutorials
HTML form, list of options or text input
Send Mail HTML Form
Upload file
how can i setup a page break for printer on html using php ?
html to php
.html or .php?
learning HTML and PHP
Does mySQL support BLOB? How?
Save as .html or .php
TMP File Problem
Help needed with getting table to auto update via html form
.html vs .php
upload file to server using html form and CGI C
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.