QImageFileAsset: How do I move the UPLOADED File to another location

Login or register to post comments
4 replies [Last post]
profnotime's picture
Offline
Joined: 01/13/2009

Hello All,

Please one of my friends just did a QForm with a QImageFileAsset to upload files. After uploads, please is there a method to move the uploaded file to another location within his application. If no method exist, please show me a sample code on how to do this.

Thanks.

Offline
Joined: 04/04/2008

Profnotime

Use the Copy Command.

This should work.
// move the picture to the new directory

if ($this->flaPicture1->File) {
copy($this->flaPicture1->File, __DOCROOT__ . __USER_IMAGE_ASSETS__ . '/' . $this->flaPicture1->FileName);

// Assign the file name to the field Page->Picture1

$this->mctPage->Page->Picture1 = $this->flaPicture1->FileName ;
}

1. flaPicture1 is container for the image I uploaded with the QImageFileAsset
2. __USER_IMAGE_ASSETS__ is a directory that I defined in the configuration file. You can hard code the directory
3. make sure the receiving directory is writable on your server.

Hope this helps.

David

profnotime's picture
Offline
Joined: 01/13/2009

Yeah it sure does. Thanks very much. However, do I need to delete the copy the TemporaryPath after this or does QCubed handle this for me?

alex94040's picture
Offline
Joined: 11/06/2008

Do a move() instead of copy() if in doubt.

Offline
Joined: 06/15/2010

tnk all...i happen to be in dis condition...tnks for d support!