Best way to move files with php

Hey all,
I've created an "Update Item" Page where the user is able to move the item from one catergory to another, however, each item has an image so the image needs to be able to move to the correct folder if the user moves the item.
Here is the code I wrote based on what I have found on the web.
A) It doesn't work
B) I've now learned this could open the site up to massive security risks.
if (array_key_exists('submit', $_POST)) {
$oldPath = $row_rsImages['parentPage'];
$newPath = $_POST['parentPage'];
$file = $row_rsImages['imageURL'];
copy('../images/photography/$oldPath/$file', '../images/photography/$newPath/$file');
Any ideas or pointers would be very welcome at this moment in time!
Cheers
T

Yep, I understand - when the user changes the category, that also updates the path to the related image. And, it sounds like you are using different folders for different categories, so is it more of an organizational thing?
I'm not trying to push yo into a different solution only because I don't know the answer to your original question, but I still would just use a single folder for all the images. If users have upload capabilities, then the folder would be by itself in the root with the correct permissions. All the sorting and filtering is done on the display pages according to the database values, User ID, category, etc.
If there's an issue with duplicate file names when a user uploads a new image, having different destination folders will decrease that possibility, but won't eliminate it. That's why the upload script should have provisions for what to do when it encounters an existing file name, to over write the file, or modify the filename. And the final version of the uploaded filename is what gets passed to the insert or update script to store it in the database.
I realize that this would require changing a number of things in your application - insert and update forms, the pages that display the images, etc and that getting the move script to work would be a quicker fix. You may ALS want to try to find out more about why that script would present any security risks in addition to just having a folder or folders with write permissions as upload repositories.

Similar Messages

  • Best way to move files to external drive in LR 5. Drag and drop or export, if drag and drop

    Best way to move files to external drive in LR 5. Drag and drop or export, if drag and drop can I put all the dated folders into one single folder

    Drag and drop should do the job. Or move the files (or folders) in your operating system and then re-link via http://www.computer-darkroom.com/lr2_find_folder/find-folder.htm
    Yes, you can put all the dated folders into a single folder (but if you plan to do this, then don't try move the files using your operating system and re-link)
    Export most definitely isn't the solution.

  • What's the best way to move files from my old G3 to my new Intel DuoCore?

    I just received my new Intel DuoCore 17" iMac. For years I have been using a much-loved G3 500 mHz iMac. The new Intel iMac is still in the box, but I believe it shipped with OS 10.4.4. The G3 runs 10.2.6. I have a dial-up connection to the Internet; currently DSL is not available in my neighborhood. What is the best way to move my files from the G3 to the Intel dc? Can I simply connect them with an Ethernet cable and transfer files directly? Or is my best bet to simply save the files I want to transfer to a disc and do it the old-fashioned way? Please forgive me in advance for my ignorance; although I have been a Mac user and supporter for many years, I am astonishingly ignorant when it comes to the best way to using both Mac hardward and software.
    iMac Intel DuoCore   Mac OS X (10.4.4)  

    There are two issues - 1. Getting the files moved over, and 2. Being able to open them on the Intel iMac.
    1. This can be technically easy if you are willing to spend the time. I moved all my stuff from my old Mac to my new one by hooking the two together with an ethernet cable, directly. You would need both machines to have appropriate IP addresses. (go to the network preferences and pull down the built-in ethernet panel.) Some addresses such as 192.168.1.100 and 192.168.1.101 would work with a subnet mask of 255.255.255.0) Now go to the new iMac and make sure the finder is selected (click on the desktop) and under the "GO" menu select "Connect to Server". You will need to put in the IP address of the old machine, and later it's administrative password. Then select its hard drive from the list (possibly only one choice) and it should appear as an icon on your iMac desktop. You can open this like any other drive and just drag items to the new iMac.
    2. Whether you can use all the files moved over from the old G3 is difficult to answer. You may be using Classic mode sometimes on the G3 and have some stuff created with a Classic application. You are probably aware that the new Intel iMac does not support Classic mode, so some of these files may not be useable without a bit of work (or at all, perhaps.) For instance I had to purchase Appleworks to handle some of my old Clarisworks documents because Pages couldn't understand them. Once I had them converted to Appleworks documents, I could then convert them again to Pages documents.
    I had some old MacDraw Pro documents that were equally problematic.
    I would advise you to get the new iMac out of the box and connected to your dialup internet connection first. Do all the software updates until running software updater says there is nothing new. Then you will be at 10.4.7 with all the latest security and fixes etc. Then disconnect from the internet and use an ethernet cable to get the stuff off the old computer.
    There will be lots more to do such as moving your mail, address box entries etc. later, but this is a start.

  • Best way to move file

    I am wondering which is the best way to move a file from one place to another?
    The following code is working for me, but I am wondering if this is considered robust?
    File oldFile = new File("C:\\toBeDeleted");
    File newFile = new File("C:\\docs\\hasBeenRenamed");
    oldFile.renameTo(newFile);
    Is it a better approach to read in the file by reader or stream, and write it out again to the new location, and then delete the original file?

    Which of those commands is non-atomic? Rename is
    atomic on all operating systems I'm aware of.
    Rename can't be used to move a file across file
    systems. However, if it can, I don't see the point of
    all the copying.From File.renameTo API:
    renameTo
    public boolean renameTo(File dest)
    Renames the file denoted by this abstract pathname.
    Many aspects of the behavior of this method are inherently platform-dependent:
    The rename operation might not be able to move a file from one filesystem to another,
    it might not be atomic, and it might not succeed if a file with the destination abstract
    pathname already exists. The return value should always be checked
    to make sure that the rename operation was successful.

  • What's the best way to move files from my 2012 iMac to my 2014 MBP?

    What’s a good way to move files from my 2012 iMac to my MBP?
    I prefer to do graphic work on my 21-inch iMac (2012 version). But when I travel I need to copy files to my 2014 MBP. I learned that my 2012 iMac is too old for use of AirDrop, so I’m copying and moving files with a flash drive. That seems slow and clumsy. Is there a better way?

    Target Disk Mode would provide a direct connection between the two Macs:
    http://support.apple.com/en-us/HT1661
    Nothing simpler than that is available.
    Ciao.

  • What is the best way to move files to different folders in a plug-in?

    I am writing a plug-in that needs to move files on the hard drive.  I am using LrFileUtils.move(from, to) and everything is fine except that the catalog is not updated when the file is moved.  After the plug-in runs I can use Library > Synchronize Folder to get the catalog back in sync with the new locations of the photos on the drive, but this manual step is less than ideal. 
    I am unable to find a way to move the files within the plug in that also updates the catalog (like dragging photos to a new location within the LR Navigator pane).  Lacking an API for this, I looked for a way to programmatic execute the Synchronize Folder menu item, but was not able to find this either..
    Can anyone recommend a better way to move photos to different folders within a plug-in that also updates the catalog?

    Hi Andy,
    There are 3 main file formats that you can consider writing your data out to in LabVIEW:
    ASCII
    Binary
    Datalog
    ASCII
    ASCII files are useful because every operating system and almost every application can read/write ASCII format files. Use ASCII files when:
    Other users or applications will need to access the data file.
    You will not need to perform random access file I/O
    File I/O speed is not crucial
    Disk space is not crucial
    Examples within LabVIEW Example Finder: Fundamentals >> File Input and Output >> Write to Text File.vi and Read from Text File.vi
    Binary
    Binary byte stream files are more specific to data storage and retrieval. Use b
    inary files when:
    File I/O will remain in LabVIEW only -- no other applications will be needing to write/read that file. There is no standard formatting for binary files and thus other applications or operating systems may be unable to read the file.
    Files are smaller than ASCII files
    Easier and faster random access to data
    Examples within LabVIEW Example Finder: Fundamentals >> File Input and Output >> Write Binary File.vi and Read Binary File.vi
    Datalog
    When to use datalog:
    If you need to record data with a mixture of types, it can be cumbersome to convert everything to ASCII or to keep track of the binary formatting.
    Datalog format is binary and internal to LabVIEW, so again only use this format if no other applications or operating systems will be needing to perform file I/O on the file.
    Examples within LabVIEW Example Finder: Fundamentals >> File Input and Output >> Write Datalog File
    Example.vi and Read Datalog File Example.vi
    Good luck!
    Kileen C.
    Applications Engineer
    National Instruments

  • Whats the best way to move files from a hard drive that wont boot?

    I made a bootable USB disk and it appears to work fine. I can still read and open files on the old disk (admin account only) from the new USB drive the old one doesn't boot. I don't have a backup but would like to move files to the USB and then reformat the old drive. 
    Whats the best way to capture the data?
    There are four user accounts on the old drive. Only one on the new drive so far. Do I need to set up four accounts on the new drive in order to copy data from each?

    Time Machine is for making backups and restoring ones it previously created. It doesn't restore data backed up or copied in other ways. In your case, it's better to use a cloning utility or manually drag the files than it is to use Time Machine.
    (124317)

  • Best way to move files to new computer?

    Struggling to move about 10,000 files from my old computer to new computer. PSE10 in both computers running on windows 7 pro. Trying to use an external hard drive, but ending up with some empty folders; and the pop up says the images are already in the catalogue. I see all the files in explorer but can't get all of them visible in all folders?
    Would I have done better connecting each computer directly?
    Basically I'm asking what is the best method to copy/move files when upgrading to a new computer?

    That is what I tried first with my Seagate external hard drive, but it would not allow restore on a different computer. It seems Seagate requires purchase of additional program to allow sharing to a different computer. So I tried using my older Lacied external hard drive with only 80gb which is less than my total catalogue size; so I could not do a simple backup and restore; so I manually dragged and dropped what would fit, ending up with the missing folders I mentioned. I just did a reconnection of files and think I finally have all folders full.
    So Seagate was a waist of money. What external hard drives work well for a backup and restore, as you suggest? Or does someone else have some other recommendations?

  • Best way to move files between FCPX and Motion?

    What is the best protocol for bringing files back and forth between Motion and FCPX?
    How do I save out from Motion for import to FCP? Is it with Templates?
    Whats the drill?
    I have looked at both the helps and am coming up short.
    Thanks.

    If you're simply working in generic Motion project, ProRes 422 Quicktime files are the best format for going back and forth.
    If you want to save a Motion project to use as a template in FCP X, it has to be one of the template Motion project types.  Title, Generator, Effect, Transition.  You would select these from the Template Browser that opens first when Motion is initially launched.
    If you want to start creating templates, I stronly recommend Ripple Training's "Rigging and Publising" video course for Motion 5.

  • Best way to share files with slow upload

    Hopefully this is the right place..
    I have a large number of files (about 500mb each) that I need to send to the states (I'm in Ireland) but don't want to have to burn discs and post them etc.
    As the title suggests I have a relatively slow upload speed. Anyone know what the best way to do this would be?
    currently I am doing 7 files that total 2.3GB by iDisk and it says it will take 13 hours..
    Regards
    Message was edited by: alex.lyons
    Message was edited by: alex.lyons

    Hi Alax
    Just a thought if there's no rush, how about investing in a 4GB flash drive or 4GB SD Card if you have a card reader on both ends and send the data that way?
    Example's:
    http://www.amazon.com/Kingston-DataTraveler-USB-Flash-Drive/dp/B000M2GYF6
    http://www.amazon.com/Sandisk-Secure-Digital-Memory-SDSDB-4096/dp/B000P1O73A
    Dennis

  • What's the best way to move files to new HD in the same PC?

    I just got a new bigger Hard drive and want to move all my iTunes files to it without having to make iTune search for them again. How should I do it?
    Will I have problems with the files I bough from iTunes store?
    Thanks
    IBM   Windows XP  

    1 Quit iTunes.
    2 Move the entire iTunes folder including music to the other drive.
    3 Restart iTunes holding (Shift-Windows, Option-Mac).
    4 Select Choose library. Select the library in the folder you just moved.
    5 Move the old iTunes folder to the trash but do not empty it.
    6 Restart iTunes normally and verify the songs work. If they do, empty the trash.

  • Best way to move files to external hard drive

    Hi All,
    My internal hard drive is nearly full.  I''ve bought a 2TB external hard drive to copy my Aperture library to. 
    I'm working on a 27" iMac (10.6.8), with a 1TB hd and Aperture 2.0.  External hard drive is an Omega eGo with firewire 800 (Mac Format).
    Looking at some of the posts here, its seems that the simplest method is to copy the library (drag and drop) to a folder on the external HD.  Then double click to open, at which point this will be the default library.  After checking all ok, delete the original library.
    I've also read suggestions that running your library on an external hard drive compromises speed, and that the files should be referenced externally with the library running internally for maximum performance.
    Can anyone give me some advice as the best method to work work from the external hard drive?  All my files are currently managed (around 820 GB)
    I like the idea of something so simple as drag and drop to change my library's location, the delete the old one. but if I'm going to switch to external hd, I'd like to set it up correctly, from the start.
    Thanks for your help.
    Richard

    Why not do this. Copy the library over to the external drive, leave the library on the internal drive alone for the moment and run off the external library.
    If Aperture performs OK for your needs leave the library on the external and delete the library on the internal drive. During this period of testing you could switch between the two in order to get  a real fell for how one performs over the other.
    If it turns out that  having the library on the external drive is causing problems then keep the library on the internal drive and switch to a referenced master setup with the masters on the external drive.
    Remember that while you are testing this out and switching between the two libraries changes made to one library ill not be reflected in the other. So just use this time for testing and make sure any work you do in one library you can redo in the other.

  • What is the best way to move files to a NAS

    Hello,
    I want to consolidate all my files on a NAS wired to my airport extreem with access by both the imac and the macbook pro. 
    Here's a bit of optional background on my situation:
    My tidy little home network consists of two computers (imac Intel Core Duo and a Mac Book Pro) and airport extreem router.  I also have a maxtor HD wired to the imac via fire wire for time machine backup.   The imac is the primary file storage location and I share the home folder and sub-folders to the mac book pro with RW access to the files.  There is not enough disk space on the imac to store all the files so I have my pictures stored on my macbook pro.
    OK so now I have several questions I'm hoping you can help me with moving all my files to the NAS. 
    Is the NAS the right approach or do I need a server.
    How can I get the Home folder to recognize or essentially sit on the NAS?  The alternative (which I do with my macbook pro) is to point the user to the remote drive my configuring the side bar links to the external drive.  I appreciate your advice here. I also know there are a bunch of details regarding moving my itunes and photo library which is a separate topic.
    How do I handle file permissions with multiple users?  Are there issues with a folder created by one user on the imac, limiting RW access by the macbook pro user?
    Regarding the NAS,  if I get a 2TB (two disk drive) NAS, I assume I can create two partitions (one for each drive) and have one for storage and another for time machine backup.  Any advice here.
    Thank you,

    Remove the hard drive and get one of these USB hard drive adapters. http://tinyurl.com/a5l2htj Then plug the adapter into your iMac to see/retrieve the files.
     Cheers, Tom

  • Best way to share files with 2 powerbooks

    Hello, I have 2 powerbooks 15" 1.67, the first one is running 10.39 the 2nd is 10.46,
    I would like to be able to share files between the 2, will it be as easy as just connecting a cable between the 2? I know how to connect one of them as an external using firewire but I would like both systems to be on...do i need to update the 10.39 to 10.46 first?

    The answer is NO.
    You do not need to have both on the same OS version...
    They are seperate machines and each OS handels stuff that takes care of all this. In fact you can do this from PC to Mac, which are different too.
    Assuming that you have a switch/router that both machines are both hooked into, then you don't need firewire - just ethernet, which is how I network mine together...
    Then from what I remember go into one of the machines.. from the system preferences go to file sharing and turn personal file sharing on.
    From the other machine with finder on the top bar cliock on "GO" then connect to server. Browse to find the other machine.
    Again it has been a while, and I don't have 2 machines currently running, but I recall that you need to copy and paste, or else you end up drragging the files from one to the other.
    I usually turn the sharing off when I'm not actually moving stuff around, probably good to have a firewall somewhere shield it from outside of your 'network'.

  • Best way to move files between drives- Advice?

    Many moons(FCP2) ago I made the mistake of dragging files from one hard drive to the other. At the time there was a media manager that was supposed to do this job but I screwed up and subsequently lost the files and had to recapture. I just bought a LaCie External 250 gb drive and I wanted to speed up my three media drives. Each of them will keep about 15 gb out of 75gb. SHould I use the LaCie software (SIlverkeeper) is there a FCP Media Manager? and do you still want to erase drives after each project or does Tiger eliminate the need for optimizing? I know these are basic questions but I'm still a bit gunshy.
    Thanks
    Enio

    And speaking of DisKWarrior - I had a panic with it last night.
    Had a fw drive with 10.3.8 on it - the drive was acting the goat and wouldn't mount, hmm I think, this is looking terminal.
    So ran DW 3.03 on it from a Tiger boot disc - no luck, error messages from DW. Cold realisation and panic slowly sets in. Then I try DW 3.02 booting off the Tiger disc again.
    Got the Panther disc back - cloned it all off. Whew.
    DW saves the day, again.
    First time I've had the latest v not rescuing an older OS disc, tho'.
    Weird - oh well, just thought I'd throw that in in case it helps someone.
    cheers

Maybe you are looking for