PHP file upload

Discussion in 'PHP' started by isnain, Jan 27, 2008.

  1. #1
    i am trying to upload an image(windows xp mypicture winter.jgp to be specific)to a folder in a server which has permission 705 . Now the problem is its getting type 3 error every time . Searching in the net i have found out that it s actually partially file uploaded error . But could not find any reasons . Can anyone point anything where i can come to know why this problem is happening?Thanks in advance.
     
    isnain, Jan 27, 2008 IP
  2. designersguru

    designersguru Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think the server should have write permission that is 777.
     
    designersguru, Jan 27, 2008 IP
  3. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    is there any other issue you think other than the permission issue cause most of the files are uploaded using the same script and same permission . But with this file and few other are not uploaded at all.
     
    isnain, Jan 27, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Therefore you would have to post the code you're using, including the HTML upload form.
     
    nico_swd, Jan 27, 2008 IP
  5. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This code is a bit complex to be posted here . I am explaining what i am doing .
    I have a HTML form which has action set and target to a iframe . As soon as the form is posted the form is not shown to be posted everything is hidden to the user. Now in the back end i have got ajax running to see how much the file have been uploaded but in the ajax file i checked the fily type,size(these were set in the session) and found null . Then I keep the entire $_POST["upload"] in the session and checked from the ajax file and found that it has type 3 error set.Any ideas what might have cause the problem?
     
    isnain, Jan 27, 2008 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Do you have enough space left? How big is the file?


    But you should really post your code, because all we can do is guess...
     
    nico_swd, Jan 27, 2008 IP
  7. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    <form name="upload_form" id='upload_form' method="post" enctype="multipart/form-data" action="includes/Imageupload.php" target='iframe_upload'>
    <input type="file" name="filetosave" class="upload" value="Paracourir" size="15" /><input type="hidden" name="hfiletosave" />
    <iframe name="iframe_upload" src="" width="400" height="20" style="display:none;border:none;"> </iframe>
    </form>
    in the image upload page:
    if ($_FILES["filetosave"]["type"] != "image/gif" && $_FILES["filetosave"]["type"] != "image/jpeg" && $_FILES["filetosave"]["type"] != "image/jpg" && $_FILES["filetosave"]["type"] != "image/bmp" && $_FILES["filetosave"]["type"] != "image/png" && $_FILES["filetosave"]["type"] != "image/pjpeg")
    {

    $_SESSION['invalid_file']=0;
    $_SESSION['chknow']=2;
    }
    elseif (file_exists("../upload/files/".$_FILES["filetosave"]["name"]))
    {
    @unlink("../upload/files/".$_FILES["filetosave"]["name"]);
    $_SESSION['invalid_file']=1;
    ;
    }
    elseif($_FILES["filetosave"]["size"] > 2048000 || $_FILES["filetosave"]["size"] == 0)
    {

    $_SESSION['invalid_file']=0;
    $_SESSION['chknow']=2;
    $_SESSION['Error_type']="Size Biggger";
    }
    else
    {
    $_SESSION['invalid_file']=1;
    $_SESSION['chknow']=1;

    }
    if($_SESSION['invalid_file']==1){
    if (!file_exists("../upload/files/".$_FILES["filetosave"]["name"]))
    {move_uploaded_file($_FILES["filetosave"]["tmp_name"],"../upload/files/".$_FILES["filetosave"]["name"]);
    }
    i am posting the code only for this image upload issue.
     
    isnain, Jan 27, 2008 IP
  8. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i forgot the submit button code to post which post this form
    <input type="button" id="bouton_submit" value="Importer" onclick="upload_image(2)" onmouseover="changeButton(this,'bouton_submit_on')" onmouseout="changeButton(this,'bouton_submit')"/>
     
    isnain, Jan 27, 2008 IP
  9. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i am really getting trouble with this, i have uploaded the same file with this same script in a different server which i have 777 permission but not in my desired server which has 705 permission. unfortunately if i try to change the permission to 777 it changes to 705 again. Please help me any ideas?
     
    isnain, Jan 27, 2008 IP
  10. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    ok now i have bypassed all the ajax part of it and made a simple form that uploads data now still i am having type 3 error can any body help me with that.
     
    isnain, Jan 28, 2008 IP