Use Upload File in row_inserting

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
kirondedshem
User
Posts: 642

Use Upload File in row_inserting

Post by kirondedshem »

I have an application where while user is on add form he has to select an excel file with a bunch of data in an upload field.
But before I allow the record to save I want to open this execl file and verify that the available data will suite my need.
I have code to read an excel file, BUT the problem is before the record is inserted the upload file in temporarily uploaded to some temporary folder, so ican reference to it using my folder path I set as file path in field settings.

WHne I var_dump the $rsnew["upload_field"] during row_inserting, All I see is the feildname, I want to access the temporary folder path that it has put the file in so I can open it and read it, run my varifications before I accept the file.

While usignmy own custom file I can sumt the form and access a file like this $FILES['excel_file']['tmp_name'], But the $FILES object if null in row_insertignas well

Has anyone done soemthing like this.


arbei
User
Posts: 9359

Post by arbei »

You can get the temp file path in Row_Inserting and Row_Updating Server Event as below.

For example:
$this-><Field>->Upload->GetTempFile();

If multiple files uploaded, a string[] will be returned from GetTempFile().

Read the function definition in the phpfn14.php of the generated file for your information.


kirondedshem
User
Posts: 642

Post by kirondedshem »

Thanks it works fine for those who might need the code

function Row_Inserting($rsold, &$rsnew) {
$the_name = CurrentPage()->import_file->Upload->GetTempFile();
}


Post Reply