Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8412031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:34:27+00:00 2026-06-10T00:34:27+00:00

I’m trying to use the following code to upload a csv file usually around

  • 0

I’m trying to use the following code to upload a csv file usually around 20,000 data into sql server database.

This code very rarely uploads successfully but usually i get the error below :

**Warning: fopen() [function.fopen]: Filename cannot be empty in C:\Inetpub\wwwroot\file.php on line 37

Warning: fgetcsv() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\file.php on line 39

Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\file.php on line 40**

<?php
if(isset($_POST['SUBMIT'])) 
{
$filename =$_FILES['sel_file']['name'];
$checkextension = explode(".",$filename);

if($checkextension[1]) == "csv")
{
$filename1 = $_FILES['sel_file']['tmp_name'];
$handle=fopen($filename1,"r");
while($data=fgetcsv($handle,1000000)) { $records = count($data);  } 
fclose($handle);
if($records==15) {
$handle=fopen($filename1,"r");
while (($data = fgetcsv($handle, 1000000,",")) !== FALSE) {
$sqlquery = "INSERT into dataupload (date, field1, field2,
field3, field4, field5, field6, field7, field8, field9,
 field10, field11, field12, field13, field14, field15)
 values ('$data[0]','$data[1]', '$data[2]','$data[3]','$data[4]', 
'$data[5]', '$data[6]', '$data[7]', '$data[8]', '$data[9]',
 '$data[10]', '$data[11]', '$data[12]', '$data[13]', '$data[14]')";
 mssql_query($sqlquery); }
 fclose($handle);
 echo "imported successfuly"; } else { echo "--sorry it is not csv file..."; }
  } }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:34:29+00:00Added an answer on June 10, 2026 at 12:34 am

    The temporary name in $_FILES['input_name']['tmp_name'] is not the name of the file you sent to the server.

    It’s a temporary name generated by PHP to make sure it can be stored in the temporary folder without overwriting other files.

    $_FILES['input_name']['name'] should contain the original name.

    This is the structure of the $_FILES array (when you upload one file only):

    array(
        'name'     => 'Original file name.ext',
        'type'     => 'mime/type',
        'tmp_name' => 'random_name',
        'error'    => 
            UPLOAD_ERR_OK ||
            UPLOAD_ERR_INI_SIZE ||
            UPLOAD_ERR_FORM_SIZE ||
            UPLOAD_ERR_NO_TMP_DIR ||
            UPLOAD_ERR_CANT_WRITE ||
            UPLOAD_ERR_EXTENSION ||
            UPLOAD_ERR_PARTIAL,
        'size'     => $file['size'][$key],
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.