How to Export invoices as pdf and print them through API in Zoho books using PHP or Javascript?

The button should print as described 2 invoice and one packing slip from the invoice details page. The option of changing print copy amount would be good but not so important as I can always use the normal print method to do this if need be. I would like the button to do the printing with no more interaction from the user. just push the button and it prints the copies

invoiceID = invoice.get("invoice_id");

invoicedate = invoice.get("date").toDate();

organizationID = organization.get("organization_id");
invoiceIdList = List();

invoiceIdList.add(invoiceID);

json = Map();

response = invokeurl
[
    
url :"https://books.zoho.com/api/v3/invoices/pdf?invoice_ids=" + invoiceIdList + "&organization_id=" + organizationID

    type :GET

    connection:"books"
];

info response;

just pdf file export not print them

Display files without block the app in php

I’m serving a php app on Apache2. In a function I simply want to display media, using php script instead of hosting the medias in a public folder on the server.

This is because I want to be able to add functions to control the permissions from the logged in user later, and check file extensions etc first.

I’ve tried fpassthru and readfile and both functions completely blocks the application. Especially when there’s a video > 10mb.

Here’s a version of the code:

display_file.php?filename=foo.jpg

if (empty($_GET['filename']))
{
    die(http_response_code(500)):
}

$filename = $_GET['filename'];
$extension = file_extension($filename); // .jpg|.mp4 etc
$mime = mime($ext); // get mine_type
$uri = '/foo/bar/'.$filename;


// Only allow sertain extensions
if (!in_array($ext, ALLOWED_FILE_EXTENSIONS)) // ['jpg','png','mp4'...]
{
    die(http_response_code(403));
}

// File doesn't exist
if (!file_exists($uri))
{
    die(http_response_code(404));
}

$size = filesize($uri);
$start = 0;
$end = $size - 1;
$time = filemtime($uri);
$expires = gmdate('D, d M Y H:i:s GMT', $time + (60 * 60));
$modified = gmdate('D, d M Y H:i:s GMT', $time);

//$fp = fopen($uri, 'rb');

header('Pragma: cache');
header('Cache-Control: max-age=31536000');
header('Expires: '.$expires);
header('Content-Type: '.$mime);
header('Content-Length: '.$size);
header('Accept-Ranges: bytes');
header("Content-Range: bytes $start-$end/$size");
header('Last-Modified: '.$modified);

//fpassthru($fp);
readfile($uri);

If I instead display the files direct through the public folder using Apache2, the app won’t be blocked.

Is there any other way to serve/display files with php user check, extensions etc. without blocking the entire app?

Controlando Datas com PHP [closed]

Galera, seguinte estou recebendo uma data do POSTGRESQL nesse formato, exemplo: 2020-01-01 e no caso preciso imprimir algumas informações percorrendo mês a mês dessa data até a data atual sempre. Porém em um certo momento a data e a impressão dos dados se repete, então percorre da data inicial 2020-01-01 até a atual 2023-10-02 nesse formato, e começa tudo dnv…

Preciso de algum exemplo de como controlar as datas mês a mês e imprimir por exemplo em uma tabela alguns dados.

Replicating Encrypting API key from PHP to Javascript

I have some logic for encrypting an API key in PHP and i want to do exactly the same in javascript, with the same results

$api_key = '7#4VBg7ZN3vGZPL4&r3Ow^k4#s2$Q9&NP!ofWJXPP*Tgg05Y05' . date('Ymd');
$encrypt_method = 'AES-256-CBC';
$salt_key = '0Ao10GYe^4EfBYMp';
$salt_iv = 'uV6h%Vl^$u1$vo4^';
base64_encode(openssl_encrypt($api_key, $encrypt_method, $salt_key, 0, $salt_iv));

I tried this code in js, but it doesnt give the same result

const CryptoJS = require('crypto-js');

const api_key = '7#4VBg7ZN3vGZPL4&r3Ow^k4#s2$Q9&NP!ofWJXPP*Tgg05Y05' + new Date().toISOString().slice(0, 10).replace(/-/g, '');
const salt_key = '0Ao10GYe^4EfBYMp';
const salt_iv = 'uV6h%Vl^$u1$vo4^';

const encrypted = CryptoJS.AES.encrypt(api_key, salt_key, {
  iv: CryptoJS.enc.Utf8.p
  mode: CryptoJS.mode.CBC,
  padding: CryptoJS.pad.Pkcs7
});

const base64Encrypted = encrypted.toString();

Avoid saving duplicate values when creating a file in php with special conditions [closed]

When running this code, the generated file repeats the date 4 times. Where is the problem? How can I make this command repeat only once under any condition? (I want to rewrite the previous file.)

Is there a code or command that I can run before the following code and it will be clear which function, file or code calls this part of the following code?

$curr_date = date("Y-m-d");
$filename = 'file.php';
$fp = fopen($filename, "a");
fwrite ($fp, $curr_date . "rn");
fclose ($fp);

Cannot modify header information – headers already sent by (output started at / [duplicate]

function display_custom_page_content() { 


$current_url = strtolower($_SERVER['REQUEST_URI']);

$last_part = basename($current_url); 

$url = get_query_var('posts');

if ($last_part == $url && $url) { 

    // Output your custom HTML content here for your custom post type
    ob_start();

    include_once(plugin_dir_path(__FILE__) . 'relatedpost.php');

    ob_end_flush();

  generate_xml_callback();

    exit;

}

  }
add_action('template_redirect', 'display_custom_page_content');

 function generate_xml_callback() {

ob_start();

// Your predefined set of URLs
$urls = array(
    'https://plezententerprise.com/storys/page1',
    'https://plezententerprise.com/storys/page2',
    'https://plezententerprise.com/storys/page3',
    // Add more URLs as needed
);

// Create a new XML document
$xml = new DOMDocument('1.0', 'UTF-8');

$xml->formatOutput = true;

// Create the root element (urlset)
$urlset = $xml->createElement('urlset');

$urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');

$xml->appendChild($urlset);

// Add predefined URLs to the sitemap

foreach ($urls as $url) {

    $urlElement = $xml->createElement('url');

    $locElement = $xml->createElement('loc', htmlspecialchars($url));

    $urlElement->appendChild($locElement);

    // Add other optional elements like lastmod, changefreq, priority if needed

    $urlset->appendChild($urlElement);
}

// Set the HTTP header for content type
header('Content-Type: application/xml; charset=UTF-8');

// Echo the XML data
echo $xml->saveXML();

// Flush the output buffer
ob_flush();

// Exit to prevent further output
exit;

}

// Register the REST API endpoint for XML generation
add_action(‘rest_api_init’, function () {

register_rest_route('smg/v1', 'generate-xml', array(

    'methods' => 'GET',
    'callback' => 'generate_xml_callback',
    'permission_callback' => '__return_true',

));

  });

i am create A Plugin  

Cannot modify header information – headers already sent by (output started at /home/plezent/domains/plezententerprise.com/public_html/wp-content/plugins/storyhandler125 (1)/my-custom-post-creator.php:256) in /home/plezent/domains/plezententerprise.com/public_html/wp-content/plugins/storyhandler125

Wampserver is running very slow [closed]

I use Wampserver 3.3.0 64 Bit.
OS Windows 11
16,0 GB RAM

When I use PhPMyAdmin my queries are running just fine. But some PHP-pages are loading extremely slow.

I unchecked the “cgi_module” => WAMP > Apache > Apache Modules>

To be sure also comment the next line in the httpd.conf file
#LoadModule cgi_module modules/mod_cgi.so

What are other options to try? It’s really annoying.

Argument #1 ($values) must be of type array, null given Laravel 9

I have 3 Models in My Laravel App like Employee , Salary and Title. Employee Model one to Many Relationship with both Salary and Title Models. Now I need update data using EmployeeController updateEmployee function using this function I need update some time all 3 tables tada also.
EmployeeController

public function updateEmployee(Request $request, $id) {
        $employee = Employee::find($id);
        $title = $employee->titles()->update($request->title);

        $salary = $employee->salaries()->update($request->salary);

        if(is_null($employee)) {
            return response()->json(['message' => 'Employee not found'], 404);
        }
        $employee->update($request->all());
        
        return response($employee, 200);
    
    }

and my api route is following

Route::put('updateEmployee/{id}','AppHttpControllersEmployeeController@updateEmployee');

Employee Model

public function titles(): HasMany
{
    return $this->hasMany(Title::class, 'emp_no');
}

public function salaries(): HasMany
{
    return $this->hasMany(Salary::class, 'emp_no');
}

Salary Model

public function employee(): BelongsTo
{
    return $this->belongsTo(Employee::class, 'emp_no');
}

Title Model

public function employee(): BelongsTo
{
    return $this->belongsTo(Employee::class, 'emp_no');
}

but when I try update using postman I got following error message
TypeError: IlluminateDatabaseEloquentBuilder::update(): Argument #1 ($values) must be of type array, null given, called in F:2023code2023apivendorlaravelframeworksrcIlluminateSupportTraitsForwardsCalls.php on line 23 in file F:2023code2023apivendorlaravelframeworksrcIlluminateDatabaseEloquentBuilder.php on line 1009
how could I fix this problem?

php – Implicit conversion from float 2.3283064365386963E-10 to int loses precision

I am using php 8.2 on windows on the following code:

    private static function urs($a, $b) {   
        $a &= 0xffffffff;
        $b &= 0x1f;
        if ($a&0x80000000 && $b>0){
            $a = ($a>>1) & 0x7fffffff;
            $a = $a >> ($b-1);
        } else {
            $a = ($a>>$b);
        }
        return $a; 
    }


$a &= 0xffffffff; <- this line giving error

Implicit conversion from float 2.3283064365386963E-10 to int loses precision

earlier on 5.4 the same function doesn’t given any error

page not redirect from laravel controller , requested by ajax

I’m creating a pos billing system in laravel, I send request by ajax to router controller, and i want to in ajax response, he redirect another page with some data for display in invoice.

My function work properly , in my browser network section, in preview have display invoice , but I want to this invoice open in another page .

enter image description here

my ajax code

enter image description here

billPrint function in controller

enter image description here

I’m trying to my invoice page open in another page , currently invoice page open in response .

Some specific truncated strings are not matched via LIKE expression in SQL

I seem to not be able to debug it, there is a binary encoded BitTorrent info-hash string truncated to 20 bytes (Sha1), the length of string in db is 32 bytes (sha2), so I do LIKE expression this way:

if (strlen($info_hash) == 32) {
    $is_bt_v2 = true;
} elseif (strlen($info_hash) == 20) {
    $is_bt_v2 = false;
}
$info_hash = rtrim(DB()->escape($info_hash), ' ');

$info_hash_where = $is_bt_v2 ? "WHERE tor.info_hash_v2 = '$info_hash'" : "WHERE tor.info_hash = '$info_hash' OR tor.info_hash_v2 LIKE '$info_hash%'";

$sql = "
    SELECT tor.topic_id, tor.poster_id, tor.tor_type, tor.info_hash, tor.info_hash_v2, u.*
    FROM " . BB_BT_TORRENTS . " tor
    LEFT JOIN " . BB_BT_USERS . " u ON u.auth_key = '$passkey_sql'
    $info_hash_where
    LIMIT 1
";
$row = DB()->fetch_row($sql);

$is_bt_v2 is just a marker with checked length of hash string, so it will be true if hash length will be 32 bytes in the future (currently not supported by standard) and the search will be performed only in v2 column for performance, else it first will be checked in v1 then v2 via LIKE expression.

In reality hash is always truncated to 20 bytes even if it is sha2, so it is being checked in both columns (only the second condition in $info_hash_where).

The thing is, if I search full 32 bytes string it will return the result, somehow it works with other v2 strings truncated to 20 bytes, but some specific strings are not found.

I spent a week checking the db settings (MariaDb), but I don’t know what is happening.

Strings (v2):

Full: 97978479e7eba00af6f24953f6b94b229b556627167b710472ad4c9bc4ceac41 // Works

Truncated: 97978479e7eba00af6f24953f6b94b229b556627 // Works

Url encoded: %97%97%84y%e7%eb%a0%0a%f6%f2IS%f6%b9K%22%9bUf%27


Full: b5c69a98c0235cc2af0fa0c956a2984dc10410b1ab0eee46c9cb0c876d0c5189 // Works

Truncated: b5c69a98c0235cc2af0fa0c956a2984dc10410b1 // DOESN’T WORK!

Url encoded: %b5%c6%9a%98%c0%23%5c%c2%af%0f%a0%c9V%a2%98M%c1%04%10%b1

Im getting the issue while passing my dropdown fields into to the controller

This is my Blade code for handling the form like my requirement is need to get the guard from the guard table need to store data in the rounds table as well as i need to store selected checkpoints
from the dropdown in the db table ,the guard data is storing perfectly but the checkpoints data is not storing im getting the error like this rounds rounds
3 / 4 requests
3.8 kB / 3.8 kB transferred
{message: “The selected checkpoints must be an array.”,…}
errors
:
{selected_checkpoints: [“The selected checkpoints must be an array.”]}
message
:
“The selected checkpoints must be an array.”

{!! Form::open(['class'=>'form-horizontal ajax_form','method'=>'POST','files' => true, 'autocomplete' => 'off']) !!}
<div class="row">
    <!-- Left Column -->
        <div class="col-md-6 col-sm-6">
            <div class="portlet light bordered">
                   <!-- Title Start  -->
                    <div class="portlet-title">
                        <div class="caption font-purple-wisteria">
                            <i class="fa fa-user font-purple-wisteria"></i>{!! trans('Round Details') !!}
                        </div>
                    </div>
                    <!-- Title  -->

                    <!-- Body Start -->
                    <div class="portlet-body">
                        <!-- Add your left column form elements here -->
                            <div class="form-group">
                                <label class="col-md-3 control-label">{{ trans('Select Guard')}} <span class="required">* </span></label>
                                <div class="col-md-9">
                                    <select class="form-control" name="guard">
                                        @foreach ($guard as $guard)
                                            <option value="{{ $guard->id }}">{{ $guard->full_name }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">{{ trans('RoundName')}}<span class="required">* </span></label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control" name="roundname" id="roundname" placeholder="{{ trans('Roundname')}}" value="{{old('roundname')}}" disabled>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">{{ trans('StartTime')}}<span class="required">* </span></label>
                                <div class="col-md-9">
                                    <input type="time" class="form-control" name="shiftstartTime" id="shiftstartTime" placeholder="{{ trans('core.shiftstartTime')}}" value="{{old('shiftstartTime')}}" onchange="updateRoundName()">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">{{ trans('EndTime')}}<span class="required">* </span></label>
                                <div class="col-md-9">
                                    <input type="time" class="form-control" name="shiftendTime" id="shiftendTime" placeholder="{{ trans('core.shiftendTime')}}" value="{{old('shiftendTime')}}" onchange="updateRoundName()">
                                </div>
                            </div>

                            <hr>
                            <button type="button" style="margin: 1% 0 1% 25%;" onclick="addEmployee();return false;" class=" btn green ">
                                {{ trans('core.btnSubmit')}}
                            </button>
                
                            <!-- Add more left column form elements as needed -->
                        
                    </div>
                    <!-- Body End -->
            </div>
        </div>

    
    <!-- Right Column -->
        <div class="col-md-6 col-sm-6">
                <div class="portlet light bordered">
                    <!-- Title Start -->
                    <div class="portlet-title">
                        <!-- Add your right column form elements here -->
                        <div class="caption font-purple-wisteria">
                            <i class="fa fa-user font-purple-wisteria"></i>{!! trans('Add Your checkPoint Here!') !!}
                        </div>
                    </div>
                    <!-- Title End -->

                    <!-- Body Start -->

                    <div class="portlet-body">
                        <!-- Add your right column form elements here -->
                        <div class="form-group">
                            <div class="col-md-10">
                              <label>{{ trans('Select Checkpoint')}} <span class="required">* </span></label>
                              <input type="hidden" name="selected_checkpoints[]" id="selected_checkpoints" value="">
                              <select class="form-control" name="selected_checkpoints[]" id="checkpoint-select">
                                @foreach ($checkpoint as $checkpoint)
                                    <option value="{{ $checkpoint->id }}">{{ $checkpoint->checkpointname }} {{ $checkpoint->id }}</option>
                                @endforeach
                            </select>


                                <button type="button" class="btn btn-success btn-sm" style="margin: 4% 14% 0% 0%;" id="add-checkpoint" onclick="addCheckpoint()">Add</button>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12">
                                <table id="selected-checkpoints-table" class="table" style="background-color:#eff1f4;">
                                    <thead>
                                        <tr>
                                            <th>Sr.No.</th>
                                            <th>Checkpoint Name</th>
                                            <th>Delete</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <!-- Selected checkpoints will be displayed here -->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        
                    </div>
                    <!-- Body End -->

                </div>
        </div>
        <!-- Right column End -->
</div>
{!! Form::close() !!}

My js code

<script>
function addEmployee() {
    // Clear any previous error messages
    $('.form-group').removeClass('has-error');
    $('.help-block').remove();

    var isValid = true;

    // Validate Full Name
    var roundName = $('input[name="roundname"]').val().trim();
    if (roundName === '') {
        isValid = false;
        $('input[name="roundname"]').closest('.form-group').addClass('has-error');
        $('input[name="roundname"]').after('<span class="help-block">Round name is required.</span>');
    }

    if (isValid) {
        // Collect selected checkpoint IDs
        var selectedCheckpointIds = Array.from(document.querySelectorAll("#selected-checkpoints-table tbody tr")).map(function (row) {
            return row.dataset.checkpointId;
        });

        // Attach selectedCheckpointIds to the form data
        $('input[name="selected_checkpoints"]').remove(); // Remove any previous hidden input
        $('<input>').attr({
            type: 'hidden',
            name: 'selected_checkpoints',
            value: JSON.stringify(selectedCheckpointIds)
        }).appendTo('.ajax_form');

        // If all validations pass, proceed with form submission
        var url = "{{ route('admin.rounds.store') }}";
        $.easyAjax({
            type: 'POST',
            url: url,
            container: '.ajax_form',
            file: true,
        });
    }
}


// updating the roundname with the start time and endtime..
    function updateRoundName() {
        var startTime = document.getElementById('shiftstartTime').value.replace(':', ''); //it Remove colons
        var endTime = document.getElementById('shiftendTime').value.replace(':', ''); // Remove colons
        var roundnameField = document.getElementById('roundname'); // getting the roundname using the id..

        // Combine the start time and end time without colons
        var roundname = startTime + '-' + endTime;

        // Update the "roundname" field value
        roundnameField.value = roundname;
    }



// Checkpoint data
// Initialize an array to store selected checkpoint IDs
var selectedCheckpointIds = [];
var rowCount = 1; // Initialize rowCount to 1

// Function to add the selected checkpoint to the selected_checkpoints field
function addSelectedCheckpoint(checkpointId) {
    var selectedCheckpointsInput = document.getElementById("selected_checkpoints");
    var selectedCheckpoints = selectedCheckpointsInput.value ? selectedCheckpointsInput.value.split(",") : [];

    // Add the checkpointId to the selectedCheckpoints array
    selectedCheckpoints.push(checkpointId);

    // Update the selected_checkpoints field with the updated array
    selectedCheckpointsInput.value = selectedCheckpoints.join(",");
}

// Function to remove the selected checkpoint from the selectedCheckpointIds array
function removeSelectedCheckpoint(checkpointId) {
    var index = selectedCheckpointIds.indexOf(checkpointId);
    if (index !== -1) {
        selectedCheckpointIds.splice(index, 1);
    }
}

function addCheckpoint() {
    var selectBox = document.getElementById("checkpoint-select");
    var selectedValue = selectBox.options[selectBox.selectedIndex].value;
    var selectedText = selectBox.options[selectBox.selectedIndex].text;

    if (selectedValue !== "") {
        // Check if the checkpoint has already been added
        var tableBody = document.querySelector("#selected-checkpoints-table tbody");
        var rows = tableBody.rows;
        for (var i = 0; i < rows.length; i++) {
            var existingValue = rows[i].cells[1].textContent;
            if (existingValue === selectedText) {
                alert("Checkpoint already added.");
                return;
            }
        }

        // Create a new row in the table and append it
        var newRow = tableBody.insertRow(tableBody.rows.length);
        newRow.insertCell(0).textContent = rowCount++; // Increment rowCount
        newRow.insertCell(1).textContent = selectedText;
        var deleteCell = newRow.insertCell(2);
        var deleteButton = document.createElement("button");
        deleteButton.textContent = "Delete";
        deleteButton.className = "btn btn-danger";
        deleteButton.onclick = function () {
            deleteRow(newRow);
            addOptionToSelect(selectedValue, selectedText);
            updateSno(); // Update the Sr.No.
            updateDropdownMessage(); // Update the dropdown message
            removeSelectedCheckpoint(selectedValue); // Remove this checkpoint from the selected_checkpoints field
        };
        deleteCell.appendChild(deleteButton);

        // Clear the selected option and remove it from the dropdown
        selectBox.remove(selectBox.selectedIndex);

        // Update the dropdown message
        updateDropdownMessage();

        // Add the selected checkpoint ID to the selectedCheckpointIds array
        selectedCheckpointIds.push(selectedValue);

        // Update the hidden input field with the selected checkpoint IDs
        document.getElementById("selected_checkpoints").value = selectedCheckpointIds.join(",");

        // Add the selected checkpoint ID to the selected_checkpoints field
        addSelectedCheckpoint(selectedValue);
    }
}




    function addOptionToSelect(value, text) {
        var selectBox = document.getElementById("checkpoint-select");
        var option = document.createElement("option");
        option.value = value;
        option.text = text;
        selectBox.appendChild(option);

        // Enable the dropdown when an option is added
        selectBox.disabled = false;

        // Update the dropdown message
        updateDropdownMessage();
    }

    function deleteRow(row) {
        var tableBody = document.querySelector("#selected-checkpoints-table tbody");
        tableBody.removeChild(row);
        updateSno(); // Update the Sr.No. after deletion

        // Enable the dropdown when a row is deleted
        var selectBox = document.getElementById("checkpoint-select");
        selectBox.disabled = false;

        // Update the dropdown message
        updateDropdownMessage();
    }

    function updateSno() {
        // Update the Sr.No. for all rows
        var tableBody = document.querySelector("#selected-checkpoints-table tbody");
        var rows = tableBody.rows;
        for (var i = 0; i < rows.length; i++) {
            rows[i].cells[0].textContent = i + 1;
        }
        rowCount = rows.length + 1; // Update the rowCount
    }


    function updateDropdownMessage() {
        var selectBox = document.getElementById("checkpoint-select");
        if (selectBox.options.length === 0) {
            selectBox.innerHTML = '<option value="">No checkpoints available</option>';
            selectBox.disabled = true;
        } else {
            // Remove the "No checkpoints available" option if it exists
            var noCheckpointOption = selectBox.querySelector('option[value=""]');
            if (noCheckpointOption) {
                selectBox.removeChild(noCheckpointOption);
            }
            selectBox.disabled = false;
        }
    }

my laravel code looks something like this

 public function store(Request $request)
{
    // Validate the form data
    $validatedData = $request->validate([
        'guard' => 'required',
        'shiftstartTime' => 'required',
        'shiftendTime' => 'required',
        'selected_checkpoints' => 'required|array', // Ensure selected_checkpoints is an array
        'selected_checkpoints.*' => 'exists:checkpoints,id', // Validate that each checkpoint exists in the "checkpoints" table
    ]);



    // Create a new round and save it
    $round = new Round();
    $round->guard_id = $validatedData['guard'];
    $round->shiftstartTime = $validatedData['shiftstartTime'];
    $round->shiftendTime = $validatedData['shiftendTime'];
    $round->save();

    // Attach selected checkpoints to the round
    $round->checkpoints()->attach($validatedData['selected_checkpoints']);

    // Redirect or return a response as needed

Errors

    im getting the error like this how to resolve this while except checkpoint field all my fields are storing in the db but the checkpointsdata is not storing
    Im getting the error like this  rounds  rounds  
    3 / 4 requests
    3.8 kB / 3.8 kB transferred
    {message: "The selected checkpoints must be an array.",…}
    errors
    : 
      {selected_checkpoints: ["The selected checkpoints must be an array."]}
message:"The selected checkpoints must be an array."

Dropzone Laravel 10

I’m trying to upload photos via Dropzone but when I try they don’t send. The function dd($request->file(‘file)) is not executed because file(‘file’) is null, and I don’t know why. Here is my script:

<script>
    Dropzone.options.fileUpload = {
        url: '{{route('admin.product.form')}}',
        addRemoveLinks: true,
        maxFilesize: 5,
        acceptedFiles: ".jpg, .jpeg, .png",
        dictRemoveFile: "Remove",
        accept: function(file) {
            let fileReader = new FileReader();

            fileReader.readAsDataURL(file);
            fileReader.onloadend = function() {

                let content = fileReader.result;
                $('#file').val(content);
                file.previewElement.classList.add("dz-success");
            }
            file.previewElement.classList.add("dz-complete");
        }
    }
</script>

Route:

Route::prefix('admin')->name('admin.')->middleware('admin')->group(function () {

    Route::get('/product', [ProductController::class, 'index'])->name('product');
    Route::post('/product', [ProductController::class, 'doProduct'])->name('product.form');
});

Controller:

  public function doProduct(Request $request)
    {

        if ($request->hasFile('file')) {
            $file = $request->file('file');
            dd($file);
            $filename = time() . '_' . $file->getClientOriginalName();
            $file->storeAs('uploads', $filename); // Записване на файла в директория 'uploads'
        }


        echo 'hello';
    }

View:

 <div class="modal-body">
                <h5 class="modal-title">Variants</h5>
                <div class="mb-8">
                    <div class="dropzone dropzone-file-area" id="fileUpload">
                        <div class="dz-default dz-message">
                            <h3 class="sbold">Drop files here to upload</h3>
                            <span>You can also click to open file browser</span>
                        </div>
                    </div>
                </div>
            </div>

in using fpdf library i cannot get a cell content in next line in the same cell itried multicell also

in particulars column the content is not wrapping in the cell , it overlaps with next cell.
in using fpdf library i cannot get a cell content in next line in the same cell itried multicell also

foreach ($transactions as $transaction) {
        $formattedDate = date('d-m-Y', strtotime($transaction['date']));
        $cellWidth =80;
        $cellHeight =5;
        if ($pdf->GetStringWidth($transaction['particulars']) > $cellWidth) {
            $line = ceil($pdf->GetStringWidth($transaction['particulars']) / ($cellWidth - $errMargin));
        } else {
            $line = 10;
        }
 $description = '';
        $bill = '';
        $status = '';
    if ($transaction['particulars'] === 'Payment Received') {
        $description = 'Payment by';
        if (!empty($transaction['payment_type'])) {
            $description .=  " - " . $paymentTypeResult[0]['payment_type'] ;
            if (!empty($transaction['ref_no'])) {
                $description .= "n   Ref No: " . nl2br($transaction['ref_no']);
        }
        $description .=  $transaction['bill_no'] ;
        }
    } else {
        $description = $transaction['particulars'];

    }   

    if ($transaction['particulars'] === 'Sales' || $transaction['particulars'] === ' Return') { 
        $bill = $transaction['bill_no'];
    }
    else {
        $bill = '';
    }
    if ($transaction['payment_status'] === '2' && $transaction['particulars'] === 'Sales') {
        $status = 'Cleared';
    }
    else if($transaction['particulars'] === 'Sales' && $transaction['payment_status'] === null ) {
        $status = 'Pending';
    }

           $pdf->Cell(22, ($line * $cellHeight ), $formattedDate, 1);
           $pdf->Cell(20,($line * $cellHeight ), $bill, 1);
        
           
           $pdf->Cell(80,($line * $cellHeight ), $description, 1);

           $pdf->Cell(20, ($line * $cellHeight ), $transaction['debit'], 1);
           
           $pdf->Cell(20, ($line * $cellHeight ), $transaction['credit'], 1);
           $pdf->Cell(20, ($line * $cellHeight ), $status, 1);
           $pdf->Ln(); // Move to the next row

           $totalDebit += floatval($transaction['debit']);
           $totalCredit += floatval($transaction['credit']);
       }

cell content overlaps to next cell

text wrapping is not working pls help

in case of using multicell code in fpdf then the result is
enter image description here

Token request getting HTTP ERROR 500 , using API by PHP cURL

trying to using an API which calling by an external link and basic token authorization.
it has 3 steps like :
1- asking for token ( every half an hour)
2- pass the token to another combo box to getting result by bearer token
3- passing same bearer token to another combo box for fetching data .
everything works fine (getting token from POSTMAN) but the problem is starting when requesting php curl calling straightforward in the codes which gives me : HTTP ERROR 500 (have to refresh token request every half an hour)
here is the code:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
 CURLOPT_URL => 'https://api.rasatpa.ir/auth/oauth/token',
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => '',
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => 'POST',
 CURLOPT_POSTFIELDS => array(,,),
 CURLOPT_HTTPHEADER => array(
   'Authorization: Basic YXRpeWVoSGNwV3M6QHRpeWUkd3NAdXNlcg=='
 ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>