SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Implementing Profile Photo Upload for Student Database

    hi there,

    I am currently develop a student database system for my faculty. I am using the PHP together with MySQL.
    I am thinking to create an option for student to upload their profile photo but I could not find any proper
    instruction or tutorial of doing that.

    Where can I look for the proper references?

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just thinking to get some sample scripts/instructions where people will register online with their picture uploaded. Then, one will be able toview the profile showing the picture that being uploaded earlier.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code processing the file uploading:

    PHP Code:
    <?php
     
    /* Script name: uploadFile.php
      * Description: Uploads a file via HTTP with a POST form. 
      */
      
    if(!isset($_POST[‘Upload’]))
      {
        include(
    “form_upload.inc”);
      }
      else   
      {
        if(
    $_FILES[‘pix’][‘tmp_name’] == “none”
        {
          echo 
    <p style=’font-weightbold’>
            
    File did not successfully uploadCheck the 
                file size
    File must be less than 500K.</p>;
          include(
    “form_upload.inc”);
          exit();
        }
        if(!
    ereg(“image”,$_FILES[‘pix’][‘type’])) 
        {
          echo 
    <p style=’font-weightbold’>
            
    File is not a picturePlease try another 
                file
    .</p>;
          include(
    “form_upload.inc”);
          exit();
        }
        else   
        {
          
    $destination=’c:\data’.\\.$_FILES[‘pix’][‘name’];
          
    $temp_file $_FILES[‘pix’][‘tmp_name’];
          
    move_uploaded_file($temp_file,$destination);
          echo 
    <p style=’font-weightbold’>
            
    The file has successfully uploaded:
                {
    $_FILES[‘pix’][‘name’]} 
                ({
    $_FILES[‘pix’][‘size’]})</p>
        }
      }
    ?>
    Code for the file upload form:
    HTML Code:
    <!-- Program Name: form_upload.inc
         Description:  Displays a form to upload a file -->
    <html>
    <head><title>File Upload</title></head>
    <body>
    <ol><li>Enter the file name of the product picture you 
            want to upload or use the browse button 
            to navigate to the picture file.</li>
        <li>When the path to the picture file shows in the
            text field, click the Upload Picture 
            button.</li>
    </ol> 
    <div align=”center”><hr />
    <form enctype=”multipart/form-data” 
            action=”uploadFile.php” method=”POST”>
      <input type=”hidden” name=”MAX_FILE_SIZE” 
             value=”500000” />
      <input type=”file” name=”pix” size=”60” />
      <p><input type=”submit” name=”Upload” 
            value=”Upload Picture” />
    </form>
    </div></body></html>
    I have no idea where is the file being uploaded to. It is not uploaded to the location as it should be. Please guide me through. Thanks in advance.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •