473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can upload files, but not a xls file.

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?
Nov 18 '08 #1
2 3181
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:
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?
Nov 20 '08 #2
Mi****************@gmail.com wrote:
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.
On Nov 18, 6:06 pm, Anthony Smith <mrsmi...@hotmail.comwrote:
>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.
js*******@attglobal.net
==================
Nov 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
5
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and...
4
by: MoroccoIT | last post by:
Greetings - I saw somewhat similar code (pls see link below) that does mupltiple files upload. It works fine, but I wanted to populate the database with the same files that are uploaded to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.