Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6242519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:58:12+00:00 2026-05-24T11:58:12+00:00

I am, using a cakephp form helper to upload images to my server. The

  • 0

I am, using a cakephp form helper to upload images to my server. The uploaded file-name gets stored in the DB but i want to store the full file-path on the server because i need this to show in
my json View(result). I tried to accomplish this with a hidden input in my form but that didn’t work so im stuck. Please any help! This is my form:

<div class="images form">
<?php // echo $this->Form->create('Image');?>
<?php echo $form->create('Image',array('type' => 'file')); ?>
<fieldset>
    <legend><?php __('Add Image'); ?></legend>
<?php
    echo $this->Form->input('gallery_id');
    echo $this->Form->input('name');
    //echo $this->Form->input('img_file');
    $form->input('img_file', array('type' => 'file'));
    echo $form->input('plaatsfoto', array('value'=>'http://localhost/tut_blog/img/uploads/images/','type' => 'hidden'));

?>
</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
<div class="actions">
<h3><?php __('Actions'); ?></h3>
<ul>

    <li><?php echo $this->Html->link(__('List Images', true), array('action' => 'index'));?      ></li>
    <li><?php echo $this->Html->link(__('List Galleries', true), array('controller' => 'galleries', 'action' => 'index')); ?> </li>
    <li><?php echo $this->Html->link(__('New Gallery', true), array('controller' => 'galleries', 'action' => 'add')); ?> </li>
</ul>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:58:12+00:00Added an answer on May 24, 2026 at 11:58 am

    You could use CakePHP’s beforeSave() function to append the path to the filename before it is saved to the database. This would allow you to manipulate the form data before it is saved to the database. CakePHP beforeSave()

    I would also check out these other resources on different methods of uploading and storing files in Cake:

    • http://www.davidgolding.net/cakephp/using-the-file-functions-in-cakephp.html
    • http://cakedc.com/florian_kraemer/2010/01/25/file-uploading-file-storage-and-cakephp-mediaview-class

      function beforeSave($options) {
      if (!empty($this->data['Image']['name'])) {
              $this->data['Image']['name'] = "/tut_blog/img/uploads/images/".$this->dateFormatBeforeSave($this->data['Image']['name']);
      
      }
      return true;}
      

    Keep in mind that there are better ways to dynamically detect an uploaded file’s path rather than putting in a static path like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload a file to my server using the CakePHP file upload
To avoid reinventing the wheel, I am generating a form using CakePHP's form helper,
Using the form helper in CakePHP 1.3, I'm trying to display a list (drop-down
Using CakePHP's form helper to generate a checkbox is easy enough; to use the
I'm using cakePHP and I want to add a First and Last name column
I'm developing a site using the CakePHP framework. I have a form which shows
I am using cakephp framework to build my application. I want that, whenever a
I'm using CakePHP to build an application using the MVC Pattern, but my question
I'm using CakePHP but it's a question about the MVC pattern. I have in
After I uploaded my application created using cakephp, I found out that I had

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.