Sending attached files in php

Discussion in 'PHP' started by 3DProf4online, Sep 29, 2008.

  1. #1
    Could you please help realize the procedure of sending attached files in php. If it is possible, please, provide me with ready code examples. Thanks in advance!
     
    3DProf4online, Sep 29, 2008 IP
  2. keyaa

    keyaa Peon

    Messages:
    137
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    At least specify the protocol you want to use to send files.
     
    keyaa, Sep 29, 2008 IP
  3. orokusaki

    orokusaki Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you're sending files in PHP, you might want to try a framework to make easier work of that. CodeIgniter.com is the best light-weight no hassle framework that doesn't rely on outside libraries.
     
    orokusaki, Sep 30, 2008 IP
  4. spc

    spc Well-Known Member

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    125
    #4
    I guess you want to send mails using php mail function with attachments.

    Please specify your requirements, so that we may help!
     
    spc, Sep 30, 2008 IP
  5. 3DProf4online

    3DProf4online Peon

    Messages:
    906
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    if for examle I am planning to develop essay writing services website, both customers and writers will need to upload .doc files attached to my website, that's why I am asking this question on how this procedure can be realized in PHP, I am just looking for PHP code examples!
     
    3DProf4online, Sep 30, 2008 IP
  6. spc

    spc Well-Known Member

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    125
    #6
    HTML code for the form to upload file. You can save this page as index.htm
    
    <html>
    <head>
    <title>File Upload Form</title>
    </head>
    <body>
    
    <form action="getfile.php" method="post"><br>
    Select File to upload: <input type="file" name="uploadFile">
    <input type="submit" value="Upload File">
    </form>
    
    </body>
    </html>
    
    Code (markup):
    Now here is the php code of getfile.php to process the uploaded file to uploads directory. That means you should create a folder named uploads in the scripts working directory before you run the script.

    
    <html>
    <head>
    <title>File Upload Status</title>
    </head>
    <body>
    <?php
    
    move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], "../uploads/{$_FILES['uploadFile'] ['name']}")
    
    ?>
    
    </body>
    </html>
    
    Code (markup):

    Hope it will help!
     
    spc, Sep 30, 2008 IP
  7. 3DProf4online

    3DProf4online Peon

    Messages:
    906
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ok, thanks spc, we will try this code later and will let you know about the results, hope this will help :)
     
    3DProf4online, Sep 30, 2008 IP
  8. khu84

    khu84 Active Member

    Messages:
    441
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #8
    khu84, Sep 30, 2008 IP
  9. 3DProf4online

    3DProf4online Peon

    Messages:
    906
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #9
    3DProf4online, Oct 1, 2008 IP