Total members 11890 |It is currently Sat Apr 20, 2024 8:09 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





If you need a code that lets my customers upload a image file from their computer and then that file does 2 things
  • gets uploaded to upload folder on my server.
  • 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...
Code:
//GET IMAGE INFO

 
$dir 'images/';
$file_name $_FILES['file']['name'];
$file_tmp $_FILES['file']['tmp_name'];
//CHECK FOR UPLOADED FILE
  
if(is_uploaded_file($file_tmp)){
 
//MOVE TO DIR
move_uploaded_file($file_tmp$dir.$file_name);
      } 





Author:
Newbie
User avatar Posts: 23
Have thanks: 1 time

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

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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>


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : Upload PHP file code
 JSP to Upload File     -  
 Upload PDF file in php     -  
 File Upload in JSP     -  
 Upload File to a new directory     -  
 upload file in ajax     -  
 Struts2 upload file and ajax     -  
 PHP HTML form with to file upload     -  
 How to upload and retrieve image in jsp please send me code     -  
 Copy file to file in java code- implementation     -  
 location of a package statement within a source code file     -  



Topic Tags

PHP Files and I/O






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com