Programming and Webmasters forum
HomeSearchRecent PostsLoginRegister Contact Us

Username  
Password
Announcing 14th Weekly Contest - From 25 July To 01 August.

Win every week on this forum.

Chek out How To Win?
 

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Code for file upload in PHP

 
webmaster forum
arsah  Offline
Contest Points: 100
 
New Poster
Posts: 2
Topics: 2
February 19, 2010, 11:41:54 PM

<html>
<head>
     <title>Upload Form</title>
</head>
<body>
<form action="UploadSingle. php" method="post" enctype="multipart/form-data">
    Upload a file: <input type="file" name="thefile"><br><br>
    <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


<!--
<?php
    $aErrors = "";
    if ( !empty( $thefile_name ) ) // no file selected
    {
        if ( ( $thefile_type == "image/gif" ) ||
             ( $thefile_type == "image/pjpeg" ) ||
             ( $thefile_type == "image/jpeg" ) ){
            if ( $thefile_size < ( 1024 * 100 ) ){
                $aCurBasePath = dirname( $PATH_TRANSLATED );
                $aNewName = $aCurBasePath .  $thefile_name;
                copy( $thefile, $aNewName );
            } else {
                $aErrors . = "The file was too big";
            }
        } else {
            $aErrors . = "The file was neither a gif nor a jpeg";
        }
    } else{
        $aErrors . = "No file was selected";
    }
?>
<html>
<head>
     <title>Display an Uploaded Image</title>
</head>
<body>
<?php
    if ( $aErrors != "" ){
        print( "<b>There were errors</b>: $aErrors<br>" );
    } else {
        print( "The picture you uploaded:<br><br>" );
        print( "<img src=\"/$thefile_name\" border=\"0\">" );
    }
?>
</body>
</html>


__________________________________
hxxp: www. self-cert-mortgage-centre. co. uk/self-certification-mortgages-uk. html
hxxp: www. equity-release-lifetime-mortgage-schemes. co. uk
 
webmaster forum
Admin  Offline
*
 
Hacker
Location: India
Gender: Male
Posts: 1101
Topics: 94
Technical_Talk
WWW
February 20, 2010, 08:41:52 AM

Thanks for sharing this code with us all.

Watch out for the latest Weekly Contests | Contest Rules
A Game - Say "Hello"
We are looking for Global Moderator
 
webmaster forum
CoderSquare.net Founder
Contest Points: 100
 
New Poster
Posts: 6
Topics: 1
WWW
April 27, 2010, 12:31:37 PM

Yeah this is definitely a useful tidbit.

www.  CoderSquare.  net
Everyone welcome! Share your code, software and games in this unique developer community! Quality submissions are given front page attention.    
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC


Google visited last this page July 29, 2010, 11:29:10 AM

Valid XHTML 1.0 Transitional     Valid XHTML 1.0 Transitional