Can upload files, but not a xls file. 
November 18th, 2008, 04:15 PM
| | | |
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? | 
November 20th, 2008, 06:05 AM
| | | | 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?
| | 
November 20th, 2008, 12:55 PM
| | | | 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
================== |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|