problem in file upload

Discussion in 'PHP' started by suzen, Jul 7, 2010.

  1. #1
    hi,
    I am unable to upload video and audio file,further more want to knosw what are setting which are required for ftp client for uploading and downlod component



    if ($_POST["fileupload"] == "Upload")
    {
    $errormsg = "";
    $photo_name = $_FILES['photo']['name'];
    //echo $photo_name;
    $photo_type = $_FILES['photo']['type'];
    //echo $_FILES['photo']['size'];
    $photo_size = $_FILES['photo']['size'];
    //echo $_FILES['photo']['tmp_name'];
    $temp=$_FILES['photo']['tmp_name'];

    }
    //echo $temp;
    //echo $photo_name;
    //echo $_FILES['photo']['size'];
    exit; //--------------------------------------------------------------------------

    if($photo_name <> "") //chk file 1 to upload
    {
    $extimage1 = explode('.',$photo_name);
    $extimage1 = $extimage1[count($extimage1)-1];
    //echo $extimage1;
    $ok = 0;

    if(($extimage1=="gif") || ($extimage1=="jpg")|| ($extimage1=="JPG") || ($extimage1=="jpeg") || ($extimage1=="pjpeg"))

    {
    $ok = 1;
    }
    }

    //----------
    if(($photo_name <> "")) //means both files to upload

    {

    if(($ok == 1) )
    {
    //echo "okies ok";
    $blupload = 1;
    }
    else
    {
    //echo "nooooooooooooo";
    $blupload = 0;
    }
    }
    //---------------------------------------
    if ($blupload == 0)
    {
    ?>
    <td height="100" align="center">&nbsp; <span class="Text">Upload Images in gif or jpg format only .</span><br>
    <p class="sublinks"><a href= "ALD.php" >Back</a></p></td>
    <?

    }

    //------------------------

    $photospath="../ProductLibrary/".$photo_name;

    // echo $photospath;
    // exit();

    if (is_uploaded_file ($_FILES['photo']['tmp_name']))
    {
    if (!move_uploaded_file ($_FILES['photo']['tmp_name'], $photospath))
    {
    $errormsg .= " Problem uploading the file. Please try again.";
    }
    }

    if($photo_name != "" && $photo_size == "0")
    {
    die("File size must be smaller than 1000k");
    ?>
    <p class="sublinks"><a href= "ALD.php" >Back</a></p>
    <?
    }



    //------------------------------

    //$imagefpath=$photospath;

    if ($photo_name <> "" )
    {
    $imagefpath=$photo_name;
    }
    else
    {
    $imagefpath= "";
    }
     
    suzen, Jul 7, 2010 IP
  2. sgcoder

    sgcoder Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    uploading huge files via http is pretty hit or miss. IME, if you keep the files to <= 500k, you shouldn't have trouble. Anything over that gets dicey as the file size increases. The webserver is more likely than not to time out. Try into ftp or fsockopen().

    <?php
    $host = 'www.example.com';
    $port = 80;
    
    $fp = fsockopen($host, $port, &$err_no, &$err_msg, 10)
        or die ("Could not open a socket connection to host <i>$host</i> on port <i>$port</i>.
            The error message returned was '<i>$err_msg</i>'.");
    
    echo "A socket connection to host <i>$host</i> on port <i>$port</i> was successfully opened."
    ?>
    
    PHP:
     
    sgcoder, Jul 7, 2010 IP