It is currently Fri Jul 30, 2010 2:08 pm


All times are UTC [ DST ]


Ask on Codemiles community and get answers Free and Fast :

PHP codes,PHP tricks ,PHP faq ,PHP answers .and more

Our guest share with us your code snippets , your programming problems , your open source projects ,read articles and post yours .







Post new topic Reply to topic  [ 3 posts ] 
  Print view Previous topic | Next topic 
Author Message
 Post subject: Upload PHP file code
PostPosted: Thu Jul 30, 2009 9:29 am 
Offline
Newbie
User avatar

Joined: Fri Jun 26, 2009 5:50 am
Posts: 23
Has thanked: 0 time
Have thanks: 0 time

Hello,

I need a code that lets my customers upload a image file from their computer and then that file does 2 things

1. gets uploaded to upload folder on my server
2. a copy of that file gets e-mailed to me

this is what I have so far, any improvements/additions on this code would really be appreciated...

1.//GET IMAGE INFO
2.
3. $dir = 'images/';
4. $file_name = $_FILES['file']['name'];
5. $file_tmp = $_FILES['file']['tmp_name'];
6.
7. //CHECK FOR UPLOADED FILE
8. if(is_uploaded_file($file_tmp)){
9. //MOVE TO DIR
10. move_uploaded_file($file_tmp, $dir.$file_name);
11. }

_________________
Thanks & regards
Lokananth
[url "http://www.mioot.com"]Live Chat Software[/url] By miOOt


TOP
 Profile Send private message  
 
| More
 Post subject: Re: Upload PHP file code
PostPosted: Thu Jul 30, 2009 12:43 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 1573
Location: Earth
Has thanked: 10 time
Have thanks: 16 time

php-tutorials/php-html-form-with-to-file-upload-t1487.html

_________________
Currenlty programming with : java , html , php , and javascript .


TOP
 Profile Send private message  
 
| More
 Post subject: Re: Upload PHP file code
PostPosted: Thu Jul 30, 2009 12:44 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 1573
Location: Earth
Has thanked: 10 time
Have thanks: 16 time

Code:
<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>

_________________
Currenlty programming with : java , html , php , and javascript .


TOP
 Profile Send private message  
 
| More
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


 Similar topics
 Topic title   Forum   Author   Replies 
 What is the code for below algorithome.  C-C++  rasel  1
 JSP to Download File  Servlets / JSP  msi_333  7
 race game source code in j2me  INDIA Jobs  sardar  0
 Struts2 upload file and ajax  Servlets / JSP  AskBot  2
 Link to download in my website..jsp or jsf to download file  Servlets / JSP  fcuritiba  2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  





Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2009
mileX v1.0 designed by codemiles team