Total members 9936 | Gratitudes |It is currently Sun Feb 05, 2012 8:04 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 3 posts ] 
Author Question
 Question 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: 1 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  
Reply with quote  
 Question 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: 2101
Location: Earth
Has thanked: 39 time
Have thanks: 56 time
php-tutorials/php-html-form-with-to-file-upload-t1487.html

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question 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: 2101
Location: Earth
Has thanked: 39 time
Have thanks: 56 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 . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 3 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Read your gmail using Java code  Java examples  msi_333  5
 What's wrong with my code?  Java  Anonymous  3
 project source code in java  Java  Anonymous  0
 Ajax Source code to Suggest application with JSP Server side  AJAX  msi_333  5
 java code to open word doc attached in ms access.db  Java  Anonymous  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




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-2011
mileX v1.0 designed by codemiles team