upload function is working in one version and not in other version

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shankari07
    New Member
    • Sep 2007
    • 16

    upload function is working in one version and not in other version

    Dear frnds,

    The following code works in 4.4.4 but not working in 4.4.8

    [PHP]
    $filen = basename($_FILE S['uploaded_file']['name']);
    $filen = basename($_FILE S['uploaded_file']['name']);

    $ext = substr($filen, strrpos($filen, '.') + 1);
    echo "filetype=" .$_FILES["embeded_fi le"]["type"];

    if (($_FILES["uploaded_f ile"]["type"] == "image/jpeg")|| ($_FILES["uploaded_f ile"]["type"] == "image/pjpeg")|| ($ext == "doc") || ($ext == "rtf") ||($ext == "pdf") || ($ext == "txt"))
    {
    if($_FILES["uploaded_f ile"]["size"] < 1048576 )
    {
    $filename = basename($_FILE S['uploaded_file']['name']);
    $ext = substr($filenam e, strrpos($filena me, '.') + 1);
    $newname = dirname(__FILE_ _).'/uploaded/'.$filename;

    [/PHP]


    can anyone help me.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    What does and doesnt happen?

    Comment

    • shankari07
      New Member
      • Sep 2007
      • 16

      #3
      thanks for the reply,

      if i try to print this statement($_FIL ES["uploaded_f ile"]["type"] ) then it is giving results in the version 4.4.4 and it is not giving the results in the version 4.4.8 and 4.3.1

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        There is nothing on php.net to suggest any bugs with the versions you speak of.


        Actually, i just noticed on line 5, it says embeded_file - shouldnt it be uploaded_file ?

        Regards

        Comment

        • shankari07
          New Member
          • Sep 2007
          • 16

          #5
          i did a mistake on line 5.even after correcting that error , am not getting the filetype
          this is my code[php]if($_POST["upload"] == "Link")
          {
          //$upload1 = $_POST["uploaded_f ile"];
          $_SESSION["uploaded_f ile"] = $_POST["uploaded_f ile"];
          if($_POST["uploaded_f ile"] !="")
          {
          $filen = basename($_FILE S['uploaded_file']['name']);
          $ext = substr($filen, strrpos($filen, '.') + 1);
          echo "filetype=" .$_FILES["uploaded_f ile"]["type"];
          if (($_FILES["uploaded_f ile"]["type"] == "image/jpeg")|| ($_FILES["uploaded_f ile"]["type"] == "image/pjpeg")|| ($ext == "doc") || ($ext == "rtf") ||($ext == "pdf") || ($ext == "txt"))
          {
          if($_FILES["uploaded_f ile"]["size"] < 1048576 )
          {
          $filename = basename($_FILE S['uploaded_file']['name']);
          $ext = substr($filenam e, strrpos($filena me, '.') + 1);
          $newname = dirname(__FILE_ _).'/uploaded/'.$filename;
          if (!file_exists($ newname)) {
          //Attempt to move the uploaded file to it's new place
          if($_SESSION["at"] < 5)
          {
          if ((move_uploaded _file($_FILES["uploaded_f ile"]["tmp_name"],$newname))) {
          // $sqli ="insert into uploadimage(upl oad_img)values( '$filename')";
          // $sqlm = mysql_query($sq li,$dbcon);
          if($_SESSION["at"] == 0)
          {
          $_SESSION["ufile"] = $filename;
          $_SESSION["filename"] = $filename;
          }
          if($_SESSION["at"] == 1)
          {
          $_SESSION["ufile1"] = $filename;
          $_SESSION["filename1"] = $filename;
          }
          if($_SESSION["at"] == 2)
          {
          $_SESSION["ufile2"] = $filename;
          $_SESSION["filename2"] = $filename;
          }
          if($_SESSION["at"] == 3)
          {

          $_SESSION["ufile3"] = $filename;
          $_SESSION["filename3"] = $filename;
          }
          if($_SESSION["at"] == 4)
          {
          $_SESSION["ufile4"] = $filename;
          $_SESSION["filename4"] = $filename;
          }
          $_SESSION["at"]= $_SESSION["at"]+1; }
          else {
          echo "Error: A problem occurred during . $filename . image upload!<br>";
          }}
          else
          {
          echo "<br><font color='red'><ce nter><b> Error: only 5 attachments allowed</b></center></font>";
          }
          } else {
          echo "<br><font color='red'><ce nter><b> Error in Attachment : Already Exists</center></b></font>";
          }
          }
          else
          {
          echo "<br><font color='red'><ce nter><b> Error in Attachement: More than 1 MB is not allowed</b></center></font>";
          }
          }
          else
          {
          echo "<br><font color='red'><ce nter><b> Error in Attachement: Invalid file</b></center></font>";
          }
          }
          if($_POST["embeded_fi le"] != "")
          {
          echo "filetype=" .$_FILES["embeded_fi le"]["type"];
          if (($_FILES["embeded_fi le"]["type"] == "image/gif") || ($_FILES["embeded_fi le"]["type"] == "image/jpeg")|| ($_FILES["embeded_fi le"]["type"] == "image/pjpeg"))
          {
          if($_FILES["embeded_fi le"]["size"] < 1048576 )
          {
          $filename_e = basename($_FILE S['embeded_file']['name']);
          $ext_e = substr($filenam e_e, strrpos($filena me_e, '.') + 1);
          $newname_e = dirname(__FILE_ _).'/embedded/'.$filename_e;
          if (!file_exists($ newname_e)) {
          //Attempt to move the uploaded file to it's new place
          if($_SESSION["ate"] < 5)
          {
          if ((move_uploaded _file($_FILES["embeded_fi le"]["tmp_name"],$newname_e))) {
          // $sqli ="insert into uploadimage(upl oad_img)values( '$filename')";
          // $sqlm = mysql_query($sq li,$dbcon);
          if($_SESSION["ate"] == 0)
          {
          $_SESSION["efile"] = $filename_e;
          $_SESSION["filename_e "] = $filename_e;
          }
          if($_SESSION["ate"] == 1)
          {
          $_SESSION["efile1"] = $filename_e;
          $_SESSION["filename_e 1"] = $filename_e;
          }
          if($_SESSION["ate"] == 2)
          {
          $_SESSION["efile2"] = $filename_e;
          $_SESSION["filename_e 2"] = $filename_e;
          }
          if($_SESSION["ate"] == 3)
          {
          $_SESSION["efile3"] = $filename_e;
          $_SESSION["filename_e 3"] = $filename_e;
          }
          if($_SESSION["ate"] == 4)
          {
          $_SESSION["efile4"] = $filename_e;
          $_SESSION["filename_e 4"] = $filename_e;
          }
          $_SESSION["ate"]= $_SESSION["ate"]+1; }
          else {
          echo "Error: A problem occurred during . $filename_e . image upload!<br>";
          }}
          else
          {
          echo "<br><font color='red'><ce nter><b> Error: only 5 Embedded images allowed</b></cetner></font>";
          }
          }
          else {
          echo "<br><font color='red'><ce nter><b> Error in Embedded file: Already Exists</b></center></font>";
          }
          }
          else
          {
          echo "<br><font color='red'><ce nter><b> Error in Embedded file: More than 1 MB is not allowed</b></center></font>";
          }
          }
          else
          {
          echo "<br><font color='red'><ce nter><b> Error in Embedded file: Invalid file</b></center></font>";
          }
          }
          }[/php]
          it is going into else part and showing error Error in Attachement: Invalid file
          Last edited by ronverdonk; Apr 9 '08, 11:02 AM. Reason: last warning: use code tags!

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            This is the last warning about using code tags:

            Please enclose your posted code in [code] tags (See How to Ask a Question).

            This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

            Please use [code] tags in future.

            MODERATOR

            Comment

            Working...