By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,007 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,007 IT Pros & Developers. It's quick & easy.

Partially Uploading Files via PHP

P: n/a
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/c1d58880229e579b1a05a4c1aee35e71Doc1.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,225)
(000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > STOR
/system/uploads/c1d58880229e579b1a05a4c1aee35e71Doc1.doc
(000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > asked to upload
'\system\uploads\c1d58880229e579b1a05a4c1aee35e71D oc1.doc' in
'C:\Server\Apache Group\Apache2\htdocs\' --> 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
c1d58880229e579b1a05a4c1aee35e71Doc1.doc.
(000001) 24/03/2006 09:17:33 - dean (127.0.0.1) > started uploading
'\system\uploads\c1d58880229e579b1a05a4c1aee35e71D oc1.doc' in
'C:\Server\Apache Group\Apache2\htdocs\'.
(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\uploads\c1d58880229e579b1a05a4c1aee35e71D oc1.doc' in
'C:\Server\Apache Group\Apache2\htdocs\' - (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\Apache
Group\Apache2\htdocs\system\uploads\c1d58880229e57 9b1a05a4c1aee35e71Doc1.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_imports();
//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

Mar 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dean Richardson wrote:
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.

Probably timing out. Tune the upload params in your php.ini.

<http://www.radinks.com/upload/config.php>
Mar 28 '06 #2

P: n/a
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.input &
arg_separator.output &
asp_tags Off
auto_append_file no value
auto_prepend_file no value
browscap no value
default_charset no value
default_mimetype text/html
define_syslog_variables Off
disable_classes no value
disable_functions 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_string no value
error_log no value
error_prepend_string no value
error_reporting 2047
expose_php On
extension_dir ./
file_uploads On
gpc_order GPC
highlight.bg #FFFFFF
highlight.comment #FF8000
highlight.default #0000BB
highlight.html #000000
highlight.keyword #007700
highlight.string #DD0000
html_errors On
ignore_repeated_errors Off
ignore_repeated_source Off
ignore_user_abort Off
implicit_flush Off
include_path .;c:\php4\pear
log_errors Off
log_errors_max_len 1024
magic_quotes_gpc On
magic_quotes_runtime Off
magic_quotes_sybase Off
max_execution_time 60
max_input_time 60
open_basedir no value
output_buffering no value
output_handler no value
post_max_size 8M
precision 12
register_argc_argv On
register_globals Off
report_memleaks On
safe_mode Off
safe_mode_exec_dir no value
safe_mode_gid Off
safe_mode_include_dir no value
sendmail_from me@localhost.com
sendmail_path no value
serialize_precision 100
short_open_tag On
SMTP localhost
smtp_port 25
sql.safe_mode Off
track_errors Off
unserialize_callback_func no value
upload_max_filesize 8M
upload_tmp_dir C:\Server\PHP\uploadtemp
user_dir no value
variables_order EGPCS
xmlrpc_error_number 0
xmlrpc_errors Off
y2k_compliance On

Apr 3 '06 #3

P: n/a
> 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.

Apr 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.