Issue with Laravel Excel When Importing Excel Files on Online Server – Zip Member Not Found

I am encountering an issue when trying to import an Excel file using Laravel Excel in my Laravel application. I have used the following code to upload and import the file:

public function import_excel(Request $request) 
{
    try {
        $this->validate($request, [
            'file' => 'required|mimes:xls,xlsx'
        ]);
    } catch (IlluminateValidationValidationException $e) {
        return redirect()->back()->withErrors($e->validator->errors())->withInput();
    }

    // capturing the excel file
    $file = $request->file('file');

    // creating a unique file name
    $nama_file = rand().$file->getClientOriginalName();

    $file->move('file_member', $nama_file);

    // importing data
    Excel::import(new MemberImport, public_path('/file_member/' . $nama_file));

    // notifying through session
    $message = [
        "status" => $file ? "success" : "failed",
        "message" => $file ? "Member Data Successfully Imported" : "Failed to Import Member Data!"
    ];

    // redirecting back
    return redirect()->route('index.member.registration')->with("message", $message);
}

However, when attempting to import the file in the production environment, I encountered the error
“Could not find zip member zip:///home/u1572391/public_html/koperasi-app/storage/framework/cache/laravel-excel/laravel-excel-wVFjYv63g1d69UTbCrnD9xb7WAc37Hse.xlsx#_rels.rels,”

indicating an issue with finding a specific member within the zip file. Can anyone provide guidance or suggestions on how to handle this error? Are there any additional configurations or steps that need to be taken in the production environment?

when I tried to import on my local site it went well but when I tried it on the online server, I got the error

Thank you very much!

Thank you very much!

Attempt to read property “id” on null In Laravel

When I’m going to update the SEO as admin from the frontend it shows me the error “Attempt to read property “id” on null” I’ve attached the error ss. Please help me asap.
enter image description here

This is my controller Code

public function updateSEO(Request $request)
    {
        // first, get the language info from db
        $language = Language::where('code', $request->language)->first();
        $langId = $language->id;

        // then, get the seo info of that language from db
        $seo = SEO::where('language_id', $langId)->first();

        // else update the existing seo info of that language
        $seo->update($request->all());

        $request->session()->flash('success', __('Updated successfully!'));

        return redirect()->back();
    }

This Is My View Code

                <div class="form-group">
                                <label>{{ __('Meta Description For Home Page') }}</label>
                                <textarea class="form-control" name="home_meta_description" rows="5"
                                    placeholder="{{ __('Enter Meta Description') }}">{{ $data->home_meta_description }}</textarea>
                            </div>

Data need to view in group

Simply i get data from query, but i need to view data on table in group basis. I need to group jointno in group i mean, need to find same data and show it one and rowspan=”count data”. this thing i already tried, and get good result.
But now i need to achieve group in lineno according to jointno, group of dia according to jointno. and same thing in lengths, thick and welder.

I try with bellow code.

<tbody>

    <?php
    include('../connect.php');
    $id = $_GET['id'];
    $resultx = $db->prepare("SELECT * FROM rt_data where report_id= :a");
    $resultx->bindParam(':a', $id);
    $resultx->execute();

    $jointNoCounts = array(); // Array to store counts for each jointno

    for ($i = 0; $rowx = $resultx->fetch(); $i++) {
        // Count occurrences of each jointno
        $jointNo = $rowx['jointno'];
        if (!isset($jointNoCounts[$jointNo])) {
            $jointNoCounts[$jointNo] = 1;
        } else {
            $jointNoCounts[$jointNo]++;
        }
    }

    $resultx->execute(); // Resetting the result set

    for ($i = 0; $rowx = $resultx->fetch(); $i++) {
    ?>

        <tr>
            <td style="text-align: center;"><?php echo $rowx['lineno']; ?></td>
            <td style="text-align: center;"><?php echo $rowx['dia']; ?></td>
            <?php
            $jointNo = $rowx['jointno'];
            if (isset($jointNoCounts[$jointNo])) {
                // Output jointno and rowspan based on count
                echo '<td style="text-align: center;" rowspan="' . $jointNoCounts[$jointNo] . '">' . $jointNo . '</td>';
                unset($jointNoCounts[$jointNo]); // Remove the count for this jointno
            }
            ?>
            <td style="text-align: center;"><?php echo $rowx['lengths']; ?></td>
            <td style="text-align: center;"><?php echo $rowx['thick']; ?></td>
            <td style="text-align: center;"><?php echo $rowx['welder']; ?></td>
            <td style="text-align: center;"><?php echo $rowx['weldref']; ?></td>

            <td style="text-align: center;"><?php echo ($rowx['slag'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['porosity'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['undercut'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['conactivity'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['express'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['lopen'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['worm'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['tung'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['crack'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['lof'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['burn'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['accuim'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['aligind'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>
            <td style="text-align: center;"><?php echo ($rowx['discon'] == 1) ? '<i class="fa fa-check"></i>' : ''; ?></td>

            <td style="text-align: center;"><?php echo $rowx['accrej']; ?></td>
            <td><?php echo $rowx['remarks']; ?></td>
        </tr>
    <?php } ?>
</tbody>

Output Screenshot

Transfer encoding not supported

Recently i faced a problem with connecting to proxmox api. code

 curl_setopt($ch, CURLOPT_URL,"https://myhost:8006/api2/json/access/ticket");
     $pf = 'username='. urlencode($this->username).'@pve&password='.urlencode($this->password);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
   curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $pf);
   curl_exec($ch)

works fine.

but

       curl_setopt($ch, CURLOPT_URL,"https://myhost:8006/api2/json/nodes/ps116/qemu/118/status/stop")
$put_post_heareds[]="CSRFPreventionToken: {$mytokenhere}"
curl_setopt($ch, CURLOPT_HTTPHEADER, $put_post_headers);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_COOKIE, "PVEAuthCookie="{$mycookiedata}");
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_exec($ch)

returns 501 chunked transfer encoding not supported

maybe someone can help with this?

i tried to add
curl_setopt($ch, CURLOPT_POSTFIELDS, []),
tried to set
$put_post_http_headers[]=”Expect:”;

tried to set CURLOPT_HTTP_VERSION to CURL_HTTP_VERSION_1_0 as chunked is http1.1 feature…
nothing helps

p.s php8.2. i found that on php7.4 all worked fine. but still can’t find difference…

as answer to comments:

i tried curl_setopt($ch, CURLOPT_ENCODING, ”); – nothing
that post at proxmox forum is mine.

yes, today i found solution. replace
curl_setopt($ch, CURLOPT_POST, 1); with curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

but why this happens? i cant find anything related in php docs…

opencart 4 Multi language Remove ?language= from Url

Hello Im trying to remove ?language= from my url in opencart 4

the exmpale is i Want the url change from this

exmpale.com/en?language=en-gb
exmpale.com/fr?language=fr

To

exmpale.com/en

First Step I added This code To (catalog/controller/startup/seo_url.php)

if($data['route'] === 'common/home') {
   if($data['language'] === 'fr' && $key ==='language') {
      $url = '/';
      unset($data[$key]);
   } elseif($data['language'] === 'en-gb' && $key ==='language') {
      $url = '/en';
      unset($data[$key]);
  }
}

that change worked and removed the ?language= from url but the route is giving me not found error

PHPStorm suggestions of dynamic class declaration

I’m using PHPStorm, and I have a class like this.

class MasterClass {
    public function getClass($className)
    {
        require_once("/php/class/$className.php");
        $newClass = new $className();
        return $newClass;
    }
}

And I call this method in my PHP file like this.

$MasterClass = new MasterClass();
$roles = $MasterClass->getClass('Roles');
$roles->

But of course, my IDE cannot show suggestions/function usage with this solution.
Is it possible to show suggestions using something like PhpDoc? I found a solution for the function usage using @see classname::method(), but I have to do it for all the methods I called.

Thank you

I tried with

/** @link Roles */
$roles = $MasterClass->getClass('Roles');

or

/** @see Roles */
$roles = $MasterClass->getClass('Roles');

Change gravityform upload folder to a new host via ftp

we have a gravityform which has a multiple upload field
and want when user upload files the files upload to a second host via ftp connection
how can we implement this?

here what we do until now
the main site is mysite.com
and the subdomain which hosted on another hsoting is
files.mysite.com

add_filter( 'gform_upload_path', 'change_upload_path', 10, 2 );
function change_upload_path( $path_info, $form_id ) {
    // FTP credentials for host two
    $ftp_host     = '***';
    $ftp_username = '***';
    $ftp_password = '***';
    
    // Remote path on host two where files should be uploaded
    $remote_path = '/public_html/guaranty_uploads/';
    
    // Connect to host two via FTP
    $ftp_connection = ftp_connect($ftp_host);
    ftp_login($ftp_connection, $ftp_username, $ftp_password);
    
    // Set the FTP upload directory on host two
    ftp_chdir($ftp_connection, $remote_path);
    
    // Update the path_info array with the FTP details
    $path_info['path'] = $remote_path;
    $path_info['url'] = 'http://files.mysite.com/guaranty_uploads/';
    $path_info['ftp_connection'] = $ftp_connection;
    
    return $path_info;
}

best regards

$.AJAX Javascript to PHP variable

I’ve got some problems with passing a variable through ajax from my javascript to php in the next file.

This is code I used to send the data of the room_id (if i go to console log it shows that ajax sends it well, but it keeps showing me the error

Error: Data not found in POST

What could be the problem here? Filenames and variables are okay. Thanks for help in advance.

        $.ajax({
            type: 'POST',
            url: 'functions.php',
            data: { room_id: selectedRoom }, 
            success: function(response) {
                console.log(response);
            },
            error: function(error) {
                console.error(error);
            }
        });
    });
});

and this code to recive that in PHP

 if ($_SERVER["REQUEST_METHOD"] == "POST") {
   
    if (isset($_POST['room_id'])) {
      
        $room_id = $_POST['room_id'];

        // Dodaj debug statement
        echo "Received room_id: " . $room_id;

       

        
        $response = $room_id;


        echo $response;
    } else {
       
        echo "Error: key not included 'room_id' in POST data.";
    }
} else {
   
    echo "Error: Data not found in POST.";
}

I’ve tried to get the variable from js to php to use it variable in SELECT query.

Woocommerce My Account – link to custom post type page of current user

On the site, users fill in a form that creates their page on the website to display information. Within the My Account page, I’ve created a link that takes the logged-in user to the WordPress dashboard where they can edit this page.

// Add Store link WooCommerce Navigation
add_filter ( 'woocommerce_account_menu_items', 'one_more_link' );
function one_more_link( $menu_links ){
    $new = array( 'stall-page' => 'Edit Stall Information' );

    $menu_links = array_slice( $menu_links, 0, 1, true ) 
    + $new 
    + array_slice( $menu_links, 1, NULL, true );

    return $menu_links;
}

// hook the URL
add_filter( 'woocommerce_get_endpoint_url', 'hook_endpoint', 10, 4 );
function hook_endpoint( $url, $endpoint, $value, $permalink ){
    if( 'stall-page' === $endpoint ) {
        $url = 'https://websitename.com/wp-admin/edit.php?post_type=stallholders';
    }
    return $url;
}

I want to take it one step further and link directly to the page they need to edit.

I’ve been experimenting and gotten as far as this:

// hook the URL
add_filter( 'woocommerce_get_endpoint_url', 'hook_endpoint', 10, 4 );
function hook_endpoint( $url, $endpoint, $value, $permalink ){
    $current_user = wp_get_current_user();
    $post_id = $current_user->post_ID;
    if( 'stall-page' === $endpoint ) {
        $url = 'https://websitename.com/wp-admin/post.php?post=' . $post_id . '&action=edit';
    }
    return $url;
}

But this is linking to the users ID and not their custom post type page?

I am trying to open a basic ecommerce codeigniter4 application but i keep getting a error

i keep getting this error –

Warning: require(C:xampphtdocsci4-cicommerce-masterappConfig/../../vendor/codeigniter4/framework/system/bootstrap.php): Failed to open stream: No such file or directory in C:xampphtdocsci4-cicommerce-masterpublicindex.php on line 36

Fatal error: Uncaught Error: Failed opening required ‘C:xampphtdocsci4-cicommerce-masterappConfig/../../vendor/codeigniter4/framework/system/bootstrap.php’ (include_path=’C:xamppphpPEAR’) in C:xampphtdocsci4-cicommerce-masterpublicindex.php:36 Stack trace: #0 {main} thrown in C:xampphtdocsci4-cicommerce-masterpublicindex.php on line 36

Doesnt matter what i do, my original website works perfectly fine but ive tried opening multiple source code files, i have updated the env file and my httpd.conf in my xammp and still no luck.

Could anybody please assist me, i would appreciate it greatly.

Kind regards and thank you in advance!

How to solve the authentication issue using PHP open_imap() function

I tried to connect to aruba mail server using PHP open_imap() function

Here is my code:

    $host = 'imap.xxx.com';   
    $port = 993;
    $username   = "[email protected]";   
    $password   = "abc";   

    $imapConnection = imap_open("{" . $host . ":" . $port . "/imap/ssl/novalidate-cert/notls/norsh}INBOX", $username, $password);

    echo $imapConnection . "<br><br>";

    echo date("d/m/Y h:m:s", time()) . "<br><br>";

    var_dump(imap_errors());

I did not find any way out using aruba mail server!

output:

array(3) {
  [0]=> string(81) "Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Authentication failed."
  [1]=> string(81) "Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Authentication failed."
  [2]=> string(82) "Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentication failed."
}

How can setup subdomain in laravel 10

I am trying to set up a subdomain in my project, but it is not working for some reason.

Route::domain('{username}.' . env('APP_URL'))->group(function () {
    return  "test";
});

It is not returning a thing. Instead, it is going to the main domain. What should I do?

PHP file transfer an Excel xls file from the server to a local PC doesn’t work

I have an Excel 2013 xls file on my server and I would like it to download to my local Windows download directory.

$filename = 'test.xls';

$file_path = $filename;

if (file_exists($file_path)) {
    // Header setzen
    header('Content-Description: File Transfer');
    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file_path));

    readfile($file_path);

    exit;
} else {
    echo 'File not found.';
}

The download works just fine but the xls file is not readable. The error message is that Excel can’t open the file because the fileformat is incorrect.

Print file modification time ISO-8601 format in PHP [duplicate]

I am trying to echo the file’s last updated time and show it as an ISO-8601 timestamp format. I tried some commands, but they didn’t get the right last modified date.

I tried:

<?php echo date("c"); ?>

But it only gets the current server time, like 2024-01-11T11:39:33+02:00, which is always changing. Same as date('c', time()).

The following two seem to get the following date: 1970-01-01T02:00:00+02:00:

$lastmod = date('Y-m-dTH:i:s+00:00');
echo date('c', $timestamp)

and

$lastmod = date('Y-m-dTH:i:s'); $tzd = date('Z'); $lastmod .= ($tzd < 0)? "-".gmdate('H:i', -$tzd) : "+".gmdate('H:i', $tzd);
echo date('c', $timestamp)

I want the last modified PHP/HTML file date (timestamp); if it was edited two days ago, it shows that date, etc.