Jump to content

Search the Community

Showing results for tags 'WireUpload'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 6 results

  1. So I am using ajax to upload an image, but I am getting the error "Method WireUpload:: save does not exist or is not callable". I am not quite sure how to go about fixing this (at the moment). elseif($config->ajax && $input->urlSegment1 == "upload-preview") { $u = $config->paths->assets . "files/pdfs/"; $title = $sanitizer->text($_POST['title']); $p = new Page(); $p->template = "preview"; $p->parent = $pages->get("/previews/"); $p->name = $title; $p->title = $title; $p->save(); $p->setOutputFormatting(false); $u = new WireUpload('preview_image'); $u->setMaxFiles(1); $u->setOverwrite(false); $u->setDestinationPath($p->preview_image->path()); $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png', 'pdf')); foreach($u->execute() as $filename) { $p->preview_image->add($filename); } $u->save(); } I compared my code to something I did previously (though previously I just posted to the current template file, not through ajax) which works, but this doesnt seem to be working. I have the _init.php file prepending as well. Does anyone have any ideas of what might be happening?
  2. Hi there. First of all, thank you for all of your work on ProcessWire, it is truly an amazing piece of work. I can't imagine developing on anything else anymore... I am having a bit of trouble uploading images through the API. I want users of the site to be able to upload images into their page. Here is the code that I have: Get the page that belongs to that user: $l = $pages->find("user_account={$user}, template=listing")->first(); Then this is the code that I am using to upload the image: if ($input->post("imagesend") == "1") { $l->setOutputFormatting(false); // instantiate the class and give it the name of the HTML field $u = new WireUpload('userfile'); // tell it to only accept 1 file $u->setMaxFiles(1); // tell it to rename rather than overwrite existing files $u->setOverwrite(false); // have it put the files in their final destination. this should be okay since // the WireUpload class will only create PW compatible filenames $u->setDestinationPath($l->files->path); // tell it what extensions to expect $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png')); // execute() returns an array, so we'll foreach() it even though only 1 file foreach($u->execute() as $filename) $l->files->add($filename); // save the page $page->save(); } The error that I am getting is: Exception: You must set the destination path for WireUpload before executing it Any ideas? Thanks!
  3. Hi, I'm working on a script that allows users to add a new Page to my installation of ProcessWire. I will explain how this script works below. The user enters some information into a simple form ^ This can include an image The form is validated with jQuery When valid, the form triggers a function through a class that handles the process I will include some of the code below. Form: <form id="entry" class="entry" method="post" action="./" name="entry" enctype="multipart/form-data"> <div class="row"> <input type="text" name="fullName" id="fullName" placeholder="Naam initiatiefhouder *" data-validation="required" /> </div> <div class="row"> <input type="text" name="projectName" id="projectName" placeholder="Projectnaam *" data-validation="required" /> </div> <div class="row"> <input type="email" name="emailAddress" id="emailAddress" placeholder="E-mailadres *" data-validation="required" /> </div> <div class="row"> <textarea name="projectDescription" id="projectDescription" placeholder="Beschrijf uw initiatief *" data-validation="required"></textarea> </div> <div class="row"> <input type="file" id="image" name="image" data-validation="mime size" data-validation-allowing="jpg, jpeg, png, gif" data-validation-max-size="2M" /> </div> <div class="row"> <input type="submit" name="submitEntry" id="submitEntry" value="Insturen" /> </div> </form> So basically the "image" field is the field that allows the user to add a file (jpg, jpeg, png, gif - max 2mb). Now, when all the information is valid it will post this form through the following function. public function pushEntry ($input, $file) { // Unset the array $this->array = []; // If there is any data if ($input) { // Get some of the variables needed $this->name = $this->sanitizer->text($input->fullName); $this->email = $this->sanitizer->email($input->emailAddress); $this->project = $this->sanitizer->text($input->projectName); $this->description = $this->sanitizer->text($input->projectDescription); // Get the date $this->date = date("d-m-Y H:i:s"); // Generate the title $this->title = "$this->project - $this->name"; $this->duplicate = $this->pages->find("title=$this->title"); // Generate the array $this->array = [ "title" => $this->title, "fullName" => $this->name, "emailAddress" => $this->email, "projectName" => $this->project, "projectDescription" => $this->description, "date" => $this->date ]; // Create the page $new = new Page(); $new->template = $this->templates->get("entry"); $new->parent = $this->pages->get("/entries/"); foreach ($this->array as $key => $value) { // Foreach key and value, create a new page $new->$key = $value; } // Check if there is any duplicates if ($this->duplicate->count() == 0) { $new->save(); } else { echo "Dit initiatief bestaat al."; exit; } // If there is an image if (!empty($file["image"]["name"])) { // Some variables $this->path = $this->config->paths->assets . "files/$new->id"; // Set the extensions $this->extensions = [ "jpg", "jpeg", "png", "gif" ]; // Do the Wire $this->image = new WireUpload($file["image"]["name"]); $this->image->setMaxFiles(1); $this->image->setOverwrite(false); $this->image->setDestinationPath($this->path); $this->image->setValidExtensions($this->extensions); // Execute and check for errors $files = $this->image->execute(); // Add the image to the page $this->fileName = $file["image"]["name"]; $this->fullPath = $this->path ."/". $this->fileName; // Move the file $new->image->add($this->fullPath); // Unlink the file unlink($this->fullPath); // Save the page $new->save($new->id); } } // Return the array return $this->array; } The script adds a page to my installation of ProcessWire perfectly; except for the file upload. I encounter the following errors; Warning: unlink(C:/wamp/www/gezondsteregio/site/assets/files/1135/dekkleden_header.1919x301.jpg): No such file or directory in C:\wamp\www\gezondsteregio\site\templates\controllers\home.php on line 106 Warning: filemtime(): stat failed for C:/wamp/www/gezondsteregio/site/assets/files/1135/dekkleden_header.1919x301.jpg in C:\wamp\www\gezondsteregio\wire\core\Pagefile.php on line 324 Warning: filemtime(): stat failed for C:/wamp/www/gezondsteregio/site/assets/files/1135/dekkleden_header.1919x301.jpg in C:\wamp\www\gezondsteregio\wire\core\Pagefile.php on line 324 I am really curious if someone can help me with this problem. I have tried this script on both my localhost (regular Apache) and my webhost (Fast CGI). Regards, Jim Oh, and I use the following script to trigger the function. $entry = new Entry(); // If there is a post if ($input->post->submitEntry && !empty($input->post->fullName) && !empty($input->post->emailAddress) && !empty($input->post->projectName) && !empty($input->post->projectDescription)): // Push the entry to the controller $entry->pushEntry($input->post, $_FILES); endif;
  4. Hi there, I found something that kept me busy for a while. Not sure if it's a bug exactly, maybe I'm missing some naming conventions. But if the form field has a dash "-" in it, wireupload fails silently (it doesn't get populated, I guess it doesn't recognise the field) I change my form field from form-files to formfiles and then it worked
  5. I'm building a smartphone app that allows users to record a voice clip and send it to our server, which runs ProcessWire. Files are sent over HTTPS Post, currently without any sort of authentication. I've succeeded using the WireUpload class to fetch the uploaded file from the $_FILES super global. Where I get in trouble is when I try to add the audio file to the audio page, where there's an Input field called 'audiofile'. Whenever I try to use any file related method, an Internal Server Error occurs. Here's my code, which runs in the page's template. <?php Header("Content-Type: text/plain"); $upload_path = $config->paths->assets . "files/audio/"; $u = new WireUpload('files'); $u->setMaxFiles(1); $u->setOverwrite(false); $u->setValidExtensions(array('mp3', 'mp4', 'm4a')); $u->setDestinationPath($upload_path); // I can confirm through my FTP client that the file sent through POST actually shows up in the $upload_path location. $fileresult = $u->execute(); // This is the File input field in my template. Doing print_r($audiofield) confirms this is an existing object. $audiofield = $fields->get("audiofile"); // Trying this for the heck of it, but all that results is HTTP 500. $audiofield->deleteAll(); foreach($fileresult as $filename) { // I've seen various examples on what to do now. Here's one that causes a 500 error. $page->'audiofile' = $upload_path . $filename; // This seems the most logical thing to do, but also causes HTTP 500. $audiofield->add($upload_path . $filename); // Unlinking succeeds (given that I comment out the lines that cause the HTTP 500 errors) unlink($upload_path . $filename); } // We never get to this phase. $page->save(); ?> Things of note: Server runs PHP 5.4.4-14+deb7u8 on Debian with Apache/2.2.22. File uploading through the admin on the audio page works without issues, also when uploading multiple files at once or sequentially. I've confirmed the owner of $upload_path to be www-data and its permissions to be 755. What's the final step I'm missing to add the audio file to the input field on my page?
  6. Hi guys, just wondering if there is a way of limiting the size of a file being uploaded through Wire Upload rather than server-wide? EDIT: Am also wondering how to output any errors the WireUpload should be outputting.
  • Create New...