Welcome Guest, Not a member yet? Register   Sign In
How to attach a file without the user being able to explore all files?
#11

Here is a start of a FileHandler Library that you can start with has rename and copy file.

CodeIgniter 4 also has a File helper that you should also look at.

PHP Code:
<?php

namespace App\Libraries;

/**
 * Class FileHandler
 *
 * @package App\Libraries
 */
class FileHandler
{

    
/**
     * Class properties go here.
     * -------------------------------------------------------------------
     * public, private, protected, static and const.
     */


    /**
     * __construct ()
     * -------------------------------------------------------------------
     *
     * Class    Constructor
     *
     * NOTE: Not needed if not setting values or extending a Class.
     *
     */
    
public function __construct()
    {

    }

    
// -------------------------------------------------------------------

    /**
     * renameFile ()
     * -------------------------------------------------------------------
     *
     * renames $oldFilename to path $newFilename
     *
     * The rename method returns true on success or false on error.
     *
     * @param  string $oldFilename
     * @param  string $newFilename
     * @return bool
     */
    
public function renameFile(string $oldFilename ''string $newFilename '') : bool
    
{
        if (empty(
$oldFilename) or empty($newFilename))
        {
            return 
false;
        }
        else
        {
            return 
rename($oldFilename$newFilename);
        }
    }

    
// -------------------------------------------------------------------

    /**
     * copyFile ()
     * -------------------------------------------------------------------
     *
     * copies $oldFilename to path $newFilename
     *
     * The copy method returns true on success or false on error.
     *
     * @param  string $oldFilename
     * @param  string $newFilename
     * @return bool
     */
    
public function copyFile(string $oldFilename ''string $newFilename '') : bool
    
{
        if (empty(
$oldFilename) or empty($newFilename))
        {
            return 
false;
        }
        else
        {
            return 
copy($oldFilename$newFilename);
        }
    }

    
// -------------------------------------------------------------------

}   // End of FileHandler Library Class.

/**
 * -----------------------------------------------------------------------
 * Filename: FileHandler.php
 * Location: ./app/Libraries/FileHandler.php
 * -----------------------------------------------------------------------
 */ 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#12

(05-09-2021, 02:36 AM)InsiteFX Wrote: Here is a start of a FileHandler Library that you can start with has rename and copy file.

CodeIgniter 4 also has a File helper that you should also look at.

PHP Code:
<?php

namespace App\Libraries;

/**
 * Class FileHandler
 *
 * @package App\Libraries
 */
class FileHandler
{

 
/**
 * Class properties go here.
 * -------------------------------------------------------------------
 * public, private, protected, static and const.
 */


 /**
 * __construct ()
 * -------------------------------------------------------------------
 *
 * Class    Constructor
 *
 * NOTE: Not needed if not setting values or extending a Class.
 *
 */
 
public function __construct()
 {

 }

 
// -------------------------------------------------------------------

 /**
 * renameFile ()
 * -------------------------------------------------------------------
 *
 * renames $oldFilename to path $newFilename
 *
 * The rename method returns true on success or false on error.
 *
 * @param  string $oldFilename
 * @param  string $newFilename
 * @return bool
 */
 
public function renameFile(string $oldFilename ''string $newFilename '') : bool
 
{
 if (empty(
$oldFilename) or empty($newFilename))
 {
 return 
false;
 }
 else
 {
 return 
rename($oldFilename$newFilename);
 }
 }

 
// -------------------------------------------------------------------

 /**
 * copyFile ()
 * -------------------------------------------------------------------
 *
 * copies $oldFilename to path $newFilename
 *
 * The copy method returns true on success or false on error.
 *
 * @param  string $oldFilename
 * @param  string $newFilename
 * @return bool
 */
 
public function copyFile(string $oldFilename ''string $newFilename '') : bool
 
{
 if (empty(
$oldFilename) or empty($newFilename))
 {
 return 
false;
 }
 else
 {
 return 
copy($oldFilename$newFilename);
 }
 }

 
// -------------------------------------------------------------------

}   // End of FileHandler Library Class.

/**
 * -----------------------------------------------------------------------
 * Filename: FileHandler.php
 * Location: ./app/Libraries/FileHandler.php
 * -----------------------------------------------------------------------
 */ 

OK, Im on v3.1.9 but intend updating to v4 when the need arises, which now maybe the time. But has it been declared stable?

Where did you get that library from? I noted Location: ./app/Libraries/FileHandler.php but could not find that link anywhere.

And where do I put it?

I note that it can copy but could not see if it can paste.

I can create a path when the advert is created, then if a line in the file can be copied like this line below, then I will need to be able to paste it into a text box, or something similar that can be posted, within the category file, then the fwrite process will do the rest.

PHP Code:
<button><a/href="/adverts/$user/drink/coke">Coke</a></button

For the system to paste it would need to open the category view page then find the word "advert" in this line

PHP Code:
<input type="text" value="<?php echo isset($_POST['advert']) ? $_POST['advert'] : '';?>" 

and paste somewhere within & I dont know where. It will be important that coding not be displayed but the BUTTON is displayed.
Reply
#13

(This post was last modified: 05-09-2021, 12:03 PM by InsiteFX.)

It's one that I have been working on it's mine but any one is welcome to it I'll be adding more to it later.

It goes in the Library folder it is for CodeIgniter 4 but should also work with CodeIgniter 3.

Also if you switch to CodeIgniter 4 @MGatner Has a file system that may help you out.

@MGatner - Tatter\Files
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#14

(05-09-2021, 11:31 AM)InsiteFX Wrote: It's one that I have been working on it's mine but any one is welcome to it I'll be adding more to it later.

It goes in the Library folder it is for CodeIgniter 4 but should also work with CodeIgniter 3.

Also if you switch to CodeIgniter 4 @MGatner Has a file system that may help you out.

@MGatner - Tatter\Files

I use UltraEdit as my text editor, that I bought over 20 years ago & it has never faltered. It has an excellent macro system, where it can "find", IfFound & IfNotFound, LeftArrow & RightArrow, Home & End, StartSelect & EndSelect, Copy & Paste, OpenFile & CloseFile, 10 Clipboards & it could achieve precisely what I need but I cant get it integrated into CI. I wrote to them a few years ago to see if it could be integrated with PHP but they said it cant. Recently I asked if they could create a combination framework/text editor but havent yet heard back. If they could do that we would have an excellent tool to develop websites. UltraEdit has an excellent help menu & is easy to follow, probably the reason it is so good.

How do you get your system to copy & paste?

If you can get your system to copy&paste & LeftArrow&RightArrow it will be a big help & a good start to a full blown editor.
Reply
#15

I think Ive got a good idea. @InsiteFX you carry on with your FileHandler, but only if you desire, work alongside an edit library that I will start. Im playing in the dark but see nothing wrong with that.

CodeIgniter Admin should get involved but I have in the past found them disinterested in critics & little interest in advancing into a worthwhile framework.

I will start a new topic that will invite contributors, so if anybody is interested just register.
Reply
#16

They are not being critic of your idea it's just that they have to keep CodeIgniter in a small foot print and fast.

Good luck on your idea and keep me post on how your making out with it. I also have an Editor that I bought along
time ago called Innova Studio Editor it works with all kinds of programming languages.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB