(where to) upload file from external form
Permalink 1 user found helpful
I have created an external form which include a file upload.
i am using
move_uploaded_file($_FILES['photo']['tmp_name'], $target)
to save the file from the form but the $target seem to block the upload and i always get a false return.
i have tried different target paths without getting anything to work. i finally tried $this->getThemePath(); as a test and it doesnt get recognized in my controller.php.
how could i get a path to upload the file and where should i put it ?
any thought welcome, i am running out of ressources. Thanks
i am using
move_uploaded_file($_FILES['photo']['tmp_name'], $target)
to save the file from the form but the $target seem to block the upload and i always get a false return.
i have tried different target paths without getting anything to work. i finally tried $this->getThemePath(); as a test and it doesnt get recognized in my controller.php.
how could i get a path to upload the file and where should i put it ?
any thought welcome, i am running out of ressources. Thanks
you mean like this?http://www.concrete5.org/documentation/developers/files/importers...
that's not exactly what i meant but it works with that so i might try that way. thanks heaps !
the only thing now is that i have no idea how to get its path.
I am storing the infos from the form into the database to be able to automaticaly display them on a page. the uploaded pics should be part of those infos but i dont know how to get to it and only have its name in the database for now. Is there a way to get the path where the photo is stored as well as its thumbnails ?
thanks again for your help.
the only thing now is that i have no idea how to get its path.
I am storing the infos from the form into the database to be able to automaticaly display them on a page. the uploaded pics should be part of those infos but i dont know how to get to it and only have its name in the database for now. Is there a way to get the path where the photo is stored as well as its thumbnails ?
thanks again for your help.
you can use getrealative path on the file id
thanks for pointing me in the right direction! for those who d try to do the same, here's how i import my file to the file manager and get the infos i need to use later.
<? php
Loader::library("file/importer");
$fi = new FileImporter();
$newfile = $fi->import(($_FILES['photo']['tmp_name']), $photoName);
$pathphoto= $newfile->getRelativePath();
$paththumb = str_replace("files","files/thumbnails/level2",$pathphoto);
$photoID= $newfile->getFileID();
?>
to get the thumbnail path, i tried to use getThumbnailSRC($level) but it didnt return anything for some reason. but the only thing that changes in the path is thumbnails/level2, so i use the str_replace function to create the path from the $pathphoto. Just change the level (1, 2 or3) depending on which one you need to use.
<? php
Loader::library("file/importer");
$fi = new FileImporter();
$newfile = $fi->import(($_FILES['photo']['tmp_name']), $photoName);
$pathphoto= $newfile->getRelativePath();
$paththumb = str_replace("files","files/thumbnails/level2",$pathphoto);
$photoID= $newfile->getFileID();
?>
to get the thumbnail path, i tried to use getThumbnailSRC($level) but it didnt return anything for some reason. but the only thing that changes in the path is thumbnails/level2, so i use the str_replace function to create the path from the $pathphoto. Just change the level (1, 2 or3) depending on which one you need to use.
Hi, I have the same problem, but when I try this, I got an empty page:
$val = Loader::helper('validation/form');
Loader::library('file/importer');
$destination_path = getcwd().DIRECTORY_SEPARATOR."bookfiles".DIRECTORY_SEPARATOR;
$fi = new FileImporter();
$newfile = $fi->import( $_FILES['uploadedphotobook']['tmp_name']);
$path= $newfile->getRelativePath();
$fileID= $newfile->getFileID();
I have checked when can I get this error. If I remove the last two lines, it's is okey.
So can anybody help me, how can I create an external form with file input and put that files into the filemanager?
$val = Loader::helper('validation/form');
Loader::library('file/importer');
$destination_path = getcwd().DIRECTORY_SEPARATOR."bookfiles".DIRECTORY_SEPARATOR;
$fi = new FileImporter();
$newfile = $fi->import( $_FILES['uploadedphotobook']['tmp_name']);
$path= $newfile->getRelativePath();
$fileID= $newfile->getFileID();
I have checked when can I get this error. If I remove the last two lines, it's is okey.
So can anybody help me, how can I create an external form with file input and put that files into the filemanager?
Having a really hard time making this work in Concrete5.7