Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Uploading Pics

  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Uploading Pics

    I used this tutorilal to help me create an upload button so a user could upload a picture. problem is, I cant tell if its working or not. the example for the tutorial is here:
    http://www.htmlgoodies.com/beyond/ph...le.php/3472551

    the example I did is on the web here:
    www.ten14.net/ten14home.swf

    (click the "come work with us" button in the top right.)

    can anyone tell me what is wrong? or right?

    Thanks
    Z

  • #2
    New Coder
    Join Date
    Sep 2005
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry didn't mean to post.

  • #3
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    I made this for multiple uploading, it should help. It was in the snippets section but apparently a mod doesn't think uploading multiple images (something you can't just do with a regular function) wasn't usefull.


    PHP Code:
    <?php

    $file_path 
    "p_images/";
    if(!(
    is_dir($file_path))) {
      if(!(
    mkdir($file_path0777))) {
        die(
    "The directory <b>".$file_path."</b> doesn't exist and could not be created!");
      }
    }

    if(isset(
    $_POST['submit'])) {
      echo 
    "<p>";
      while(list(
    $key,$val) = each($_FILES['imagefiles']['name'])) {
        if(isset(
    $val)) {
       
          
    $filename $val;
          
    $file $_FILES['imagefiles']['tmp_name'][$key];
        
          if (
    preg_match("/.(jpg|jpeg|png|gif)/i"$filename)) {
              
    $valid true;
          } else {
              
    $valid false;
          }
        
            if (
    $valid) {
        
            
    $ext substr($filenamestrpos($filename".")+1strlen($filename));
            
    $new_filename substr(md5(microtime()), 08).".".$ext;
        
            if(@
    copy($file$file_path $new_filename)) {
              if(@
    chmod($file_path $new_filename0777)) {
                echo 
    "<b>Image " $key "</b>: <a href=\"http://" $_SERVER['HTTP_HOST'] . "/" $file_path $new_filename "\" target=\"_blank\">http://" $_SERVER['HTTP_HOST'] . "/" $file_path $new_filename "</a><br />\n";
              } else {
                echo 
    "<b>Image " $key "</b>: <a href=\"http://" $_SERVER['HTTP_HOST'] . "/" $file_path $new_filename "\" target=\"_blank\">http://" $_SERVER['HTTP_HOST'] . "/" $file_path $new_filename "</a> FAILED TO CHMOD!<br />\n";
              }
            }
          }
        
        }
        
        echo 
    "</p>";
        
      }
      
    } else {

      echo 
    "<form method=\"post\" action=\"" $_SERVER['REQUEST_URI'] . "\" enctype=\"multipart/form-data\">\n";
      for(
    $i=1$i<=6$i++) {
          
    $format $i "" "<br />";
          echo 
    "<input type=\"file\" name=\"imagefiles[]\">" $format "\n";
      }
      echo 
    "<input type=\"submit\" name=\"submit\" value=\"Upload Images\">";
      echo 
    "</form>";
      
    }

    ?>

  • #4
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Element
    PHP Code:
    $file_path "p_images/"
    I assume that in the quotations is where I would put the name of the file in the server that is holding all the pics?

    THANKS I'm going to try this out...

    Z

  • #5
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Let me show you what I have....

    I have a button, that when clicked takes you here

    http://www.ten14.net/step1.html

    here is my code for that page.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Work For Ten14 | You must complete each step!</title>
    <style type="text/css">
    <!--
    body {
    	background-image: url(ten14bg.png);
    }
    .style2 {color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; }
    .style3 {
    	font-size: 24px;
    	font-weight: bold;
    }
    .style5 {font-size: 24px}
    .style6 {color: #FFFFFF}
    .style7 {
    	color: #FFFFFF;
    	font-style: italic;
    }
    .style8 {color: #600000}
    -->
    </style>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    </head>
    
    <body>
    <div id="Layer1" style="position:absolute; left:341px; top:115px; width:463px; height:229px; z-index:1">
      <p class="style2"><span class="style3">STEP 1</span><span class="style5">:</span></p>
      <p class="style2">Please upload a photo of yourself. </p>
      
      <form action="getfile.php" method="post"><br></br>
        <span class="style6">Upload File:</span>
        <input type="file" name="uploadFile" />
        <input type="submit" value="Upload File"/>
    	<input type="hidden" name="MAX_FILE_SIZE" value="25000" />
    </form>
    
      <p class="style7"> (you must complete this step to full out application)</p>
    </div>
    </body>
    </html>

    Now it's supposed to call this php code:
    Code:
    <html>
    <head>
    <title>Process Uploaded File</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
    <!--
    body,td,th {
    	color: #FFFFFF;
    }
    body {
    	background-image: url(ten14bg.png);
    }
    -->
    </style></head>
    <body>
    
    
    <?php
    
    if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], 
           "../uploads/{$_FILES['uploadFile'] ['name']}")  )
          {  print '<p> The file has been successfully uploaded </p>';
           }
    else
          { 
            switch ($_FILES['uploadFile'] ['error'])
             {  case 1:
                       print '<p> The file is bigger than this PHP installation allows</p>';
                       break;
                case 2:
                       print '<p> The file is bigger than this form allows</p>';
                       break;
                case 3:
                       print '<p> Only part of the file was uploaded</p>';
                       break;
                case 4:
                       print '<p> No file was uploaded</p>';
                       break;
             }
           }
    
    ?>
    
    
    </body>
    </html>
    I tried to substitute your php file for mine, but yours has 6 uploading buttons, and when I tried to submit a file, it still just went to a blank browser screen. I chenges my file directory to p_images. (I left my previous one as well uploads on the server too) I'm very confused....please help...thanks!

    z


  •  

    Posting Permissions

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