Jump to content

Add file description on frontend upload


Vayu Robins
 Share

Recommended Posts

Hi.

I have created a form with the API, which lets users who are logged in to upload files from the front end. I would like to be able to add the filename to the description field, but cannot seem to find a way to do this.

When a form i submitted I use this to add a file to the page.

$files = explode( "|", $form->get( "cv_file" )->value );
foreach( $files as $file ){
	if( $file && file_exists( $upload_path . $file ) ){
		$page->cv_file->add( $upload_path . $file );
		//$page->cv_file->file->description' = "TEST";
		unlink( $upload_path . $file );
	}
}
$page->of( false );
$page->save();

Is it even possible?

Link to comment
Share on other sites


$files = explode( "|", $form->get( "cv_file" )->value );

foreach( $files as $file ){

if( $file && file_exists( $upload_path . $file ) ){

$page->cv_file->add( $upload_path . $file );

$page->cv_file->last()->description = $file;

unlink( $upload_path . $file );

}

}

$page->of( false );

$page->save();

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...