Jump to content

Search the Community

Showing results for tags 'file'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. I wish to show various bits of information on a File repeater (extension, filesize etc). The filename shows correctly, but the links to the files open the admin area, the file extension is empty and the filesize too. function renderDocumentLibrary($page) { $out = ""; if ($page->document_download->count()) { print_R($page); $out .= "<div class='row downloads'>"; foreach($page->document_download as $download) { $out .= "<div class='col-xs-12 col-sm-6'>"; $out .= "<div class='download clearfix'>"; $out .= "<a href='{$download->url}'><img src='{$download->ext}' alt='Download {$download->document_name}' class='download-icon' /></a>"; $out .= "<div class='download-content'>"; $out .= "<span class='download-date'>" . date('d.m.y', $download->modified) . "</span><br />"; $out .= "<h2 class='h4'>{$download->document_name}</h2>"; $out .= "<a href='{$download->url}' class='download-link'>Download {$download->ext} ({$download->filesizeStr})</a></div>"; $out .= "</div></div>"; } $out .= "</div>"; } return $out; } Can I access those attributes in this way?
  2. Hello All, I am trying to upload multiple PDF files into one repeater field. The exact situation is, if someone submits the form. make newItem in repeater add all the PDFs in newItem. every thing is working without repeaters(files not getting replaced). But in repeater, only last file remains exist.Other PDFs getting replaced from the newItem field of repeater. My code looks like- $p2= pages->get($id); $pdfs = new WireUpload('f_plan'); $pdfs->setMaxFiles(8); $pdfs->setOverwrite(false); $pdfs->setDestinationPath($upload_path); $pdfs->setValidExtensions(array('pdf','xps')); // execute upload and check for errors $pdf_files = $pdfs->execute(); echo count($pdf_files); //count is working if(!count($pdf_files)) { $pdfs->error("Sorry, but you need to add a photo!"); return false; } foreach($pdf_files as $filename) { $p2->of(false); $new_rep = $p2->floor_plan_rep->getNew(); $p2->save(); echo $pathname = $upload_path . $filename; //all the urls are okey $new_rep->floor_plan = $pathname; $p2->save(); $p2->of(true); unlink($pathname); } Also it is making one extra blank repeater field inside repeater.(I know something is wrong and something is missing in my code. ). Please help. Thanks
  3. Hi guys, I have a requirement for a new input field for Form Builder. Essentially I just need to have some radio buttons which use an image as their label. I have managed to create the module, have it install automatically and create a new form with my custom input type but I am having trouble handling the image which is being uploaded as the label. The value for imageLabel is always an empty array. I have looked all around the forums and I Google but I cant find the answer close to what Im looking for. Do I handle the file upload manually and extract/add it to my imageField during POST and GET? I've tried multiple different methods and been through most of the API too but can't figure out the correct way to do this. <?php class InputfieldImageRadios extends InputfieldRadios { const CONFIGNAME = "ImageRadios"; public static function getModuleInfo() { return array( 'title' => __('Radio Buttons with Image Label', __FILE__), 'summary' => __('Radio buttons for selection of a single item with an extra image label', __FILE__), 'version' => 1, 'singular' => true, 'autoload' => true, 'requires' => array('InputfieldRadios', "FormBuilder") ); } public function init() { parent::init(); } public function ___getConfigInputFields() { $inputFields = parent::___getConfigInputfields(); $imageField = wire('modules')->get('InputfieldFile'); $imageField->label = $this->_('Image Label'); $imageField->description = $this->_('If you want the label to be displayed as an image.'); $imageField->extensions = 'jpg jpeg png gif'; $imageField->maxFiles = 1; $imageField->maxFileSize = 200000; $imageField->overwrite = false; $imageField->destinationPath = wire("config")->paths->files . "radioLabels/"; $imageField->name = "imageLabel"; $imageField->type = 'file'; $imageField->value = array(); $inputFields->add($imageField); return $inputFields; } public function set($key, $value) { if($key == 'imageLabel') { $test = 1; } return parent::set($key, $value); } /** * Install the module append to Form Builder config * */ public function ___install() { $formBuilderClass = "FormBuilder"; $this->verifyDependencies([$formBuilderClass]); $formBuilderConfig = wire("modules")->getModuleConfigData($formBuilderClass); if (in_array(self::CONFIGNAME, $formBuilderConfig['inputfieldClasses'])) { return; } $formBuilderConfig['inputfieldClasses'][] = self::CONFIGNAME; wire("modules")->saveModuleConfigData($formBuilderClass, $formBuilderConfig); } protected function verifyDependencies($classes) { foreach ($classes as $class) { if (!wire('modules')->isInstalled($class)) { $this->error(self::CONFIGNAME . " dependency not installed: $class"); } } } /** * Uninstall the module and remove from Form Builder config * */ public function ___uninstall() { $formBuilderClass = "FormBuilder"; $this->verifyDependencies([$formBuilderClass]); $formBuilderConfig = wire("modules")->getModuleConfigData($formBuilderClass); foreach ($formBuilderConfig['inputfieldClasses'] as $key => $value) { if ($value == self::CONFIGNAME) { unset($formBuilderConfig['inputfieldClasses'][$key]); } } wire("modules")->saveModuleConfigData($formBuilderClass, $formBuilderConfig); } }
  4. Hello again. I have a silly problem. I feel a bit ashamed, really, but I have been searching for some time now, and I can't seem to find the issue. I have a simple site (first one I made with PW, actually), with a "file" field on a "news" template/page. So the webmaster can add a downloadable file to his news. It works fine, actually, but the field description, which should appear on the page, doesnt show up for guests. It does, as long as I am connected as an admin. But guest users (visitors) can't see it. No text is rendered. (the link itself is working.) I get the same result on local and distant site. I dont get it. Have I missed a permission setting or something ? The code for rendering the link is as follow : When connected as an admin, this outputs, for example, the following code : However, for a guest, the result is : Whatever I do. In the DB, the description is stored as : I have probably missed a simple setting somewhere about permissions. But I can't seem to find it. Maybe I'm just slow-brained today... Help ? Please ?
  5. Hi, I'm just trying to delete file field via API. I want to delete it completely without concerning which pages is using it. I found this code: $fields = wire('fields'); foreach ($fields->find('name=field_name') as $field) { foreach ($field->getFieldgroups() as $fieldgroup) { $fieldgroup->remove($field); $fieldgroup->save(); } $fields->delete($field); } This removes the field from database it is OK. But it doesn't remove the files (from filesystem) that ware added to pages. As I was going through PW source code I've found that I have to save the page also, but it really complicates the thing. The problem starts in FieldtypeFile::___deletePageField method where the $pagefile is handled differently according to field output formatting. If the $pagefile is PageFile, the unlink is called which also deletes the file from filesystem. If the $pagefile is PageFiles the deleteAll is called which only adds hooks on page save. Why is it done this way? This makes inconsistency when deleting the field. Is there some better way to delete the field without caring about pages?
  6. Hey guys, I'm creating a form via the API where a user can create a page and click to "create and duplicate". The idea is that this reloads the form with a GET variable to the page just created, takes the image from that page and also adds it to the new duplicate page. Essentially there may be 4 pages created but they should all share the same file. Would it be necessary to create a new WireUpload on every page creation or is there some way to do the following (or some variation): $duplicate_page->file->add($just_created_page->file); OR $duplicate_page->file->add($just_created_page->file->url); I don't seem to be able to pull this off but perhaps it's because the WireUpload needs to take place on every page creation.. Anyone had any experience with this? Thanks
  7. Hi there, I am kinda new to PW but I gave it a try for a current project and I am pretty amazed so far. It really works great and allthough I have pretty much no knowledge about PHP I can wrap my mind around these functions and also get lots of my queries working. My site is almost complete but I also struggeling with a problem which is the following. I am building a website for a music label. They want to provide a dedicated press and download area where press people can download latest press releases, music, artworks and stuff like this. The site structure should be like this: www.domain.com - Page 1 - Page 2 - and so on and the press area which should be www.domain.com/press The link to the press area is not visible on the main website. The page is hidden and should have a simple protection with htaccess. No user or login / member management required. Just a simple htaccess password protection. How can I do that? What I would normally do is just create a folder "press" on my FTP directory where I put the htaccess and thats it but how can I accomplish this in PW? I also provide downloads on that press page. These files for download have been uploaded via the backend and now sit in the assets/file folders. How can I protect them from being downloaded? I want to achieve that once people got access to www.domain.com/press that they are also able to download these files. Maybe its a simple task but I am not sure how to do this properly. Thanks for your help - I really appreciate all that kind support here in the forum! Cheers, Martin
  8. It will allow not to allow file load .psd with expansion on .jpg. Example: I have an external form. In type of a field it is specified (to allow.jpg.jpeg). But it is enough to rename only expansion as it will be possible to load and.psd and.png and.pdf and.php. Besides, everyone will be processed on a miscellaneous, instead of as jpg. For the sake of dough I suggest to load psd renamed into jpg
  9. Hi there, When I upload my files on the image field, it changes their name and uploads a file with a different name. In this case I am building a Retina ready site and I really need these files t be uploaded as they are. Their names end with '@2x', so 'file@2x.png' could be an example, but when I upload it, the file that appears on the assets/files/ folder is named 'file_2x.png'. How can I control this? Thanks
  10. Hi all, I have a situation in which a user can upload a file that's any one of a number of formats (pdf, mpg, jpg, etc.). If the file is an image, I want to do some resizing. However, when I call ->size(###,###) on the file field when an image is in it, I get an error. Makes sense. I'm hoping there's an easy way to solve this without needing to create a separate field for image uploads. I tried following @Soma's advice from this thread, but kept getting an error from ImageSizer saying I was passing in invalid format. I know the file in there is an image as it's getting displayed in the browser. So, is there a standard way to convert a File field to an Image field? Thanks.
  11. Hi, sorry, me again, I hope these nagging questions of mine may hopefully serve other people one day I have pages which contain files, which I can then link to students and I want to be able to flash up "New!" or some such like if the file has been added or updated within say 3 days. I've figured it out to check whether the page itself containing the file has been added or modified. $files = $file_page->files; foreach ($file_pages as $file_page) { $create_date = $file_page->created; $mod_date = $file_page->modified; $date_trigger = strtotime("-3days"); ?> <li><a href="<?php echo $file->url; ?>"><?php if ($file->description) {echo $file->description;} else { echo $file->name;} ?></a> <?php if ($mod_date>$date_trigger && $create_date<$date_trigger) {echo "Recently modified!";} ?> <?php if ($create_date>$date_trigger) {echo "New!";} ?> </li> Was wondering if it would be able to go one level deeper as I have some file pages with multiple files. If not, it's no big deal, but would be helpful. Thanks again.
  12. Hi y'all! Im am trying to force a file download after user submits a form. When user hits submit button POST data are send to a template (sort of "thank you for downloading" page). This template on successful submission redirects to another template through this code <?php $downloadurl = $pages->get('/download/')->url; header('refresh: 0; url='.$downloadurl); ?> Redirection then hits this template code (located in download template): <?php // filename & url of the pdf file $filename = $pages->get('/some-page/')->file->name; $fileurl = $pages->get('/some-page/')->file->url; $filesize = $pages->get('/some-page/')->file->filesize; // force download of the file header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename='.$filename); header("Content-Length: ".$filesize); readfile($fileurl); It downloads a file and then redirects back to thank you page. The only problem is that the downloaded file is empty (0KB). When i download a file "the standard way" clicking on a link that directs to $pages->get('/some-page/')->plik->url; everything is ok. Any ideas?
×
×
  • Create New...