Partially Uploading Files via PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dean Richardson

    Partially Uploading Files via PHP

    Hi,

    I'm having trouble uploading files via a PHP script. Whenever I upload
    a file greater than 10K, the file gets corrupted. However, text files
    upload OK.


    When I check the FTP Server log I find this:


    (000001) 24/03/2006 09:17:32 - dean (127.0.0.1) > logged in.
    (000001) 24/03/2006 09:17:32 - dean (127.0.0.1) > 230 User dean logged
    in.
    (000001) 24/03/2006 09:17:32 - dean (127.0.0.1) > TYPE I
    (000001) 24/03/2006 09:17:32 - dean (127.0.0.1) > 200 Type set to I.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > SIZE
    /system/uploads/c1d58880229e579 b1a05a4c1aee35e 71Doc1.doc
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > 550 No such file or
    directory.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > EPSV
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > 500 Unknown command.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > PASV
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > 227 Entering Passive
    Mode (127,0,0,1,33,2 25)
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > STOR
    /system/uploads/c1d58880229e579 b1a05a4c1aee35e 71Doc1.doc
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > asked to upload
    '\system\upload s\c1d58880229e5 79b1a05a4c1aee3 5e71Doc1.doc' in
    'C:\Server\Apac he Group\Apache2\h tdocs\' --> Access allowed.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > 150 Data connection
    accepted from 127.0.0.1:4479; transfer starting for
    c1d58880229e579 b1a05a4c1aee35e 71Doc1.doc.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > started uploading
    '\system\upload s\c1d58880229e5 79b1a05a4c1aee3 5e71Doc1.doc' in
    'C:\Server\Apac he Group\Apache2\h tdocs\'.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > QUIT
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > 221 Bye bye ...
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > aborted uploading
    '\system\upload s\c1d58880229e5 79b1a05a4c1aee3 5e71Doc1.doc' in
    'C:\Server\Apac he Group\Apache2\h tdocs\' - (00:00:01 - 7.031 KB -
    7.031 KBytes/s).
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > file partially
    uploaded : 'C:\Server\Apac he
    Group\Apache2\h tdocs\system\up loads\c1d588802 29e579b1a05a4c1 aee35e71Doc1.do ­c'

    deleted.
    (000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > disconnected.
    (00:00:00)


    For some reason, I can run my PHP script on a third party server and it

    works OK, so something tells me that I am missing something.


    The php script is below:


    $uploaddir = init_upload_imp orts();
    //copy the file to some permanent location
    if (move_uploaded_ file($_FILES["userfile"]["tmp_name"], $uploaddir .
    $custno.$_FILES["userfile"]["name"]))
    {
    $v_attachments= $custno.$_FILES["userfile"]["name"];
    }
    else
    {
    echo ("error!");
    }


    Any help would be very much appreciated.


    Thanks in Advance.
    Dean

  • void * clvrmnky()

    #2
    Re: Partially Uploading Files via PHP

    Dean Richardson wrote:[color=blue]
    > Hi,
    >
    > I'm having trouble uploading files via a PHP script. Whenever I upload
    > a file greater than 10K, the file gets corrupted. However, text files
    > upload OK.
    >
    >[/color]
    Probably timing out. Tune the upload params in your php.ini.

    <http://www.radinks.com/upload/config.php>

    Comment

    • Dean Richardson

      #3
      Re: Partially Uploading Files via PHP

      Hi,

      I checked the phpinfo and cannot find anything out of the ordinary. The
      upload times out in one second or thereabouts.
      I have included the phpinfo below.

      Thanks,
      Dean.


      allow_call_time _pass_reference On
      allow_url_fopen On
      always_populate _raw_post_data Off
      arg_separator.i nput &
      arg_separator.o utput &
      asp_tags Off
      auto_append_fil e no value
      auto_prepend_fi le no value
      browscap no value
      default_charset no value
      default_mimetyp e text/html
      define_syslog_v ariables Off
      disable_classes no value
      disable_functio ns no value
      display_errors On
      display_startup _errors Off
      doc_root no value
      docref_ext no value
      docref_root no value
      enable_dl On
      error_append_st ring no value
      error_log no value
      error_prepend_s tring no value
      error_reporting 2047
      expose_php On
      extension_dir ./
      file_uploads On
      gpc_order GPC
      highlight.bg #FFFFFF
      highlight.comme nt #FF8000
      highlight.defau lt #0000BB
      highlight.html #000000
      highlight.keywo rd #007700
      highlight.strin g #DD0000
      html_errors On
      ignore_repeated _errors Off
      ignore_repeated _source Off
      ignore_user_abo rt Off
      implicit_flush Off
      include_path .;c:\php4\pear
      log_errors Off
      log_errors_max_ len 1024
      magic_quotes_gp c On
      magic_quotes_ru ntime Off
      magic_quotes_sy base Off
      max_execution_t ime 60
      max_input_time 60
      open_basedir no value
      output_bufferin g no value
      output_handler no value
      post_max_size 8M
      precision 12
      register_argc_a rgv On
      register_global s Off
      report_memleaks On
      safe_mode Off
      safe_mode_exec_ dir no value
      safe_mode_gid Off
      safe_mode_inclu de_dir no value
      sendmail_from me@localhost.co m
      sendmail_path no value
      serialize_preci sion 100
      short_open_tag On
      SMTP localhost
      smtp_port 25
      sql.safe_mode Off
      track_errors Off
      unserialize_cal lback_func no value
      upload_max_file size 8M
      upload_tmp_dir C:\Server\PHP\u ploadtemp
      user_dir no value
      variables_order EGPCS
      xmlrpc_error_nu mber 0
      xmlrpc_errors Off
      y2k_compliance On

      Comment

      • milahu

        #4
        Re: Partially Uploading Files via PHP

        > However, text files upload OK.

        Try FTP's binary mode for binary files. You can find the file's
        MIME-type in $_FILES['...']['type'].
        If it starts with text/... you can transfer in ASCII mode as you seem
        to do now.

        Comment

        Working...