Hello all,
ok, I have a file upload secton to my site, two pages, one with a
form and one that does the uploading.... some files upload fine, other
don't
an exe of 300k will upload, but a word document of 40k wont and so on,
in the php.ini a limit of 2mb is set (I haven't changed it, it's how
the file originally as, so it isn't my maths that's gone mad).
The code was taken more or less from the php manual... any iedas
people? Please? I'm going mad! And just when I was starting to enjoy
PHP :-(
Many thanks,
Amy
<?php
session_start() ;
$uploaddir = '/home/sites/site1/web/translation/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
{
$msg = "File (" . $_FILES['userfile']['name'] . ") is valid, and
was successfully uploaded. ";
//print_r($_FILES );
session_registe r('content-type');
session_registe r('file-name');
session_registe r('jobid');
$jobid = time();
//rename the file with the jobid before it,
$rename = $jobid . $_FILES['userfile']['name']; //or $rename =
$username;
$file_name = $_FILES['userfile']['name'];
$read_extension = explode(".", $file_name);
$ext = $read_extension[1];
rename($file_na me, $rename);
} else {
$msg = "File did not upload successfully, close window and try
again\n";
$msg = $msg . print_r($_FILES );
}
?>
ok, I have a file upload secton to my site, two pages, one with a
form and one that does the uploading.... some files upload fine, other
don't
an exe of 300k will upload, but a word document of 40k wont and so on,
in the php.ini a limit of 2mb is set (I haven't changed it, it's how
the file originally as, so it isn't my maths that's gone mad).
The code was taken more or less from the php manual... any iedas
people? Please? I'm going mad! And just when I was starting to enjoy
PHP :-(
Many thanks,
Amy
<?php
session_start() ;
$uploaddir = '/home/sites/site1/web/translation/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
{
$msg = "File (" . $_FILES['userfile']['name'] . ") is valid, and
was successfully uploaded. ";
//print_r($_FILES );
session_registe r('content-type');
session_registe r('file-name');
session_registe r('jobid');
$jobid = time();
//rename the file with the jobid before it,
$rename = $jobid . $_FILES['userfile']['name']; //or $rename =
$username;
$file_name = $_FILES['userfile']['name'];
$read_extension = explode(".", $file_name);
$ext = $read_extension[1];
rename($file_na me, $rename);
} else {
$msg = "File did not upload successfully, close window and try
again\n";
$msg = $msg . print_r($_FILES );
}
?>
Comment