Connecting Tech Pros Worldwide Forums | Help | Site Map

Can upload files, but not a xls file.

Anthony Smith
Guest
 
Posts: n/a
#1: Nov 18 '08
What am I doing wrong? I will show my form and the action page. A csv
file works fine.

<form action="/CompRun/index.php?cmd=uploadEligibilityValidation"
method="POST" enctype="multipart/form-data">
<input type = "file" name="eligVal">
<input type="submit" name="submit" value="Submit">
</form>


if (isset($_FILES['eligRev'])){
$file = $_FILES['eligRev']['tmp_name'];
$fp = fopen($file , 'r') or die("can't open file");
insertEligibilityRevenueFile($file, $_SESSION["year"], $_SESSION
["qtr"]);
fclose($fp) or die("can't open file");
$msg = "Data successfully uploaded.";
$smarty->assign('msg', $msg);
$smarty->display('uploadEligRev.tpl');
}

else{
$smarty->assign('next', $_SERVER['PHP_SELF']."?
cmd=uploadEligibilityRevenue");
$smarty->display('uploadEligRev.tpl');
}

When I upload a xls, it always just goes to the else, when I upload
anything else, I get the result I expected.

Am I missing a setting somewhere?
Mindaugas.Liubinas@gmail.com
Guest
 
Posts: n/a
#2: Nov 20 '08

re: Can upload files, but not a xls file.


Hi,

your form input name is different, i.e. in the form is name="eligVal"
and you're checking for "eligRev".

Next, don't do that: "isset($_FILES['eligRev']", it's better to do
like this:

if (is_uploaded_file($_FILES['eligVal']['tmp_name']))...

and then check for correct Mime type.

good luck!

On Nov 18, 6:06 pm, Anthony Smith <mrsmi...@hotmail.comwrote:
Quote:
What am I doing wrong? I will show my form and the action page. A csv
file works fine.
>
<form action="/CompRun/index.php?cmd=uploadEligibilityValidation"
method="POST" enctype="multipart/form-data">
<input type = "file" name="eligVal">
<input type="submit" name="submit" value="Submit">
</form>
>
if (isset($_FILES['eligRev'])){
$file = $_FILES['eligRev']['tmp_name'];
$fp = fopen($file , 'r') or die("can't open file");
insertEligibilityRevenueFile($file, $_SESSION["year"], $_SESSION
["qtr"]);
fclose($fp) or die("can't open file");
$msg = "Data successfully uploaded.";
$smarty->assign('msg', $msg);
$smarty->display('uploadEligRev.tpl');
>
}
>
else{
$smarty->assign('next', $_SERVER['PHP_SELF']."?
cmd=uploadEligibilityRevenue");
$smarty->display('uploadEligRev.tpl');
>
}
>
When I upload a xls, it always just goes to the else, when I upload
anything else, I get the result I expected.
>
Am I missing a setting somewhere?
Jerry Stuckle
Guest
 
Posts: n/a
#3: Nov 20 '08

re: Can upload files, but not a xls file.


Mindaugas.Liubinas@gmail.com wrote:
Quote:
Hi,
>
your form input name is different, i.e. in the form is name="eligVal"
and you're checking for "eligRev".
>
Next, don't do that: "isset($_FILES['eligRev']", it's better to do
like this:
>
if (is_uploaded_file($_FILES['eligVal']['tmp_name']))...
>
and then check for correct Mime type.
>
good luck!
>
Actually, he is also correct. You should check to see if the value is
set before you see if it is an uploaded file.
Quote:
On Nov 18, 6:06 pm, Anthony Smith <mrsmi...@hotmail.comwrote:
Quote:
>What am I doing wrong? I will show my form and the action page. A csv
>file works fine.
>>
><form action="/CompRun/index.php?cmd=uploadEligibilityValidation"
>method="POST" enctype="multipart/form-data">
><input type = "file" name="eligVal">
><input type="submit" name="submit" value="Submit">
></form>
>>
>if (isset($_FILES['eligRev'])){
> $file = $_FILES['eligRev']['tmp_name'];
> $fp = fopen($file , 'r') or die("can't open file");
> insertEligibilityRevenueFile($file, $_SESSION["year"], $_SESSION
>["qtr"]);
> fclose($fp) or die("can't open file");
> $msg = "Data successfully uploaded.";
> $smarty->assign('msg', $msg);
> $smarty->display('uploadEligRev.tpl');
>>
>}
>>
>else{
> $smarty->assign('next', $_SERVER['PHP_SELF']."?
>cmd=uploadEligibilityRevenue");
> $smarty->display('uploadEligRev.tpl');
>>
>}
>>
>When I upload a xls, it always just goes to the else, when I upload
>anything else, I get the result I expected.
>>
>Am I missing a setting somewhere?
>

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Closed Thread