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
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    File upload issue

    I am trying to upload files to my server via PHP but can only do it on certain files.

    if I try articles.doc it uploads fine but if I do Azul Azul - La Bomba.mp3 it won't upload.

    Here is my code:
    PHP Code:
    $hz=$_POST['hz'];
    if(
    $hz=="eklez"){

    $resimadi $_FILES['userfile']['name'];
    $uploadfile =$uploaddir.'/'$resimadi;




    move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);

    What could be the issue?

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Location
    Grahamstown, South Africa
    Posts
    237
    Thanks
    6
    Thanked 17 Times in 17 Posts
    there could be a number of details:

    1.) Check the phpinfo(); for details on:
    max_execution_time
    post_max_size
    upload_max_filesize
    If you are having problems because of your php settings, then use .htaccess or your php.ini file.
    2.) Rename the file before using move_uploaded_file();

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Do you realise how insecure that is? Hope thats not the whole script.

  • #4
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    Yeah I realize it's insecure. I stripped it down to find the error. I will try renaming it and see if that works.

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,049
    Thanks
    2
    Thanked 317 Times in 309 Posts
    It is highly likely that an upload error is occurring (having something to do with the size of the file.) ALL code must test for any available error before attempting to use data. Read the discussion about the ['error'] element and the possible error values at this link - http://us2.php.net/manual/en/features.file-upload.php

    I believe that link also mentions if you exceed the post_max_size setting that the $_FILES array will be null/not set (the $_POST array will be null/not set as well) and this condition needs to be tested for.
    Last edited by CFMaBiSmAd; 05-10-2008 at 06:31 PM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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