PHP file upload program (two simple file upload programs) _ PHP Tutorial

Source: Internet
Author: User
Tags php file upload
Php file upload program (two simple file upload programs ). Php file upload program (two simple file upload programs) * these two file upload programs are very simple and suitable for beginners to learn php file Upload instance tutorials. Php Tutorial php file upload program (two simple file upload programs)/* these two file upload programs are very simple, it is suitable for beginners to learn php file Upload instance tutorials.

Php Tutorial file upload program (two simple file upload programs)
/*
These two file upload programs are very simple and suitable for beginners to learn php file Upload instance tutorials.
*/

If (! $ Uploadaction ):
?>



File upload interface







Else:
?>



File upload code

$ Uploadaction = 0;
Echo "good! ";
$ Timelimit = 60;/* Set the time-out period. The default time is 30 seconds. if the value is 0, the time-out period is not limited */
Set_time_limit ($ timelimit );

If ($ uploadfile! = "None "))
{
$ Uploadpath = addslashes (dirname ($ path_translated). "upload"; // upload file storage path

$ Filename = $ uploadpath. $ uploadfile_name; // upload file name

If ($ uploadfile_size <1024) // upload the file size
{
$ Filesize = (string) $ uploadfile_size. "byte ";
}
Elseif ($ uploadfile_size <(1024*1024 ))
{
$ Filesize = number_format (double) ($ uploadfile_size/1024), 1). "kb ";
}
Else {
$ Filesize = number_format (double) ($ uploadfile_size/(1024*1024), 1). "mb ";
}

If (! File_exists ($ filename ))
{
If (copy ($ uploadfile, $ filename ))
{Echo "file $ uploadfile_name ($ filesize) uploaded successfully! ";}
Else
{Echo "file $ uploadfile_name Upload failed! ";}

Unlink ($ uploadfile );
}
Else
{Echo "file $ uploadfile_name already exists! ";}
}
Else
{Echo "you have not selected any file upload! ";}

Set_time_limit (30); // restores the default timeout value.

?>


Return


Endif;
?>

Method 2



File Upload






















If (isset ($ submit )){If ($ myfile! = "None "){$ Upload_dir = "c: winnttemp ";$ Up = copy ($ myfile, $ upload_dir );If ($ up = 1 ){Print ("file uploaded successfully! ");}Else {Print ("file Upload failed .");}Unlink ($ myfile );}Else {Print ("You have not uploaded any files ");}}?>



Http://www.bkjia.com/PHPjc/444862.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444862.htmlTechArticlephp file upload program (two simple file upload program)/* these two file upload program is very simple, very suitable for beginners to learn php file Upload instance tutorial Oh. Php Tutorial...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.