PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old March 24th, 2016, 02:33 PM
popeye's Avatar
popeye popeye is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: New York, New York
Posts: 41 popeye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 49 m 36 sec
Reputation Power: 11
FIle upload and file move

I have been trying to get user point to an excel file, upload and move it to a new location on the server and read it into an array using SimpleXLSX. But I can not either move the file or get SimplXLSX to load the array. Any help appreciated. See below:
Thx

<html>
<form action="Upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="i_ExcelFile" id='i_ExcelFile'/>
<input type="submit" name="submit" value="Save" />
</form>
</html>


PHP Code:
<?php
require_once "./SimpleXLSX/simplexlsx.class.php";
extract($_POST); 
if (
is_uploaded_file($_FILES['i_ExcelFile']['tmp_name'])) {
  
$i_TempFile=$_FILES['i_ExcelFile']['tmp_name'];
  echo 
"Temp File: "$i_TempFile;
  
$i_TargetFile=$_FILES['i_ExcelFile']['name'];
  echo 
"<br>Target File: "$i_TargetFile;
  if (
move_uploaded_file($i_TempFile$i_TargetFile)) {
    
$i_ExcelData = new SimpleXLSX($i_TargetFile);
    echo 
'<br>';print_r$i_ExcelData->rows());
  }
  else {
    echo 
"<br>Possible File Move  Error: ";
  }
}
else {
  echo 
"<br>Possible Temp File Upload Error: ";
}
echo 
'<br>End.';
?>
__________________
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. -Stephen Hawking

Last edited by markroberts : March 24th, 2016 at 02:55 PM.

Reply With Quote
Old June 10th, 2016, 11:19 AM
cwf's Avatar
cwf cwf is offline
Super Moderator
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 391 cwf User rank is Private First Class (20 - 50 Reputation Level)cwf User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 16 h 58 m 47 sec
Reputation Power: 11
Quote:
Originally Posted by popeye
But I can not either move the file or get SimplXLSX to load the array.


@popeye, in case you revisit this thread. You didn't stated what sort of error or symptom you are getting that lets you know you cannot move the file or get the simplxlsx class to load the array.

If you are getting your "Possible Temp File Upload Error:" message, it means that the file didn't upload. You should always test if the upload was successful before trying to use the uploaded file information. You would check the value in the $_FILES['i_ExcelFile']['error'] element to test for errors. There is also a case where the $_FILES array is empty, when you exceeded the post max size settings, that needs to be tested for first.

If you are getting your "Possible File Move Error:" messages, it most likely means php couldn't move the file due to a permission problem. Having php's error_reporting set to E_ALL and display_errors set to ON would report problems like a permission problem.

Last edited by cwf : June 10th, 2016 at 11:27 AM.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > FIle upload and file move


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap