Connecting Tech Pros Worldwide Help | Site Map

Can upload files, but not a xls file.

  #1  
Old November 18th, 2008, 04:15 PM
Anthony Smith
Guest
 
Posts: n/a
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?
  #2  
Old November 20th, 2008, 06:05 AM
Mindaugas.Liubinas@gmail.com
Guest
 
Posts: n/a

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?
  #3  
Old November 20th, 2008, 12:55 PM
Jerry Stuckle
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Webclient UploadFile "could not find file c:\..." =?Utf-8?B?U2NvdHQgVHJpY2s=?= answers 6 October 31st, 2008 10:25 PM
How to sort files by Date with this Script? aRTx answers 3 August 22nd, 2008 06:09 PM
IE 'hangs' when I try to display an uploaded file tomhawkins1@gmail.com answers 9 June 27th, 2008 05:15 PM
Upload file to Access database via form Stephan answers 3 January 18th, 2007 11:55 AM