CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Other Programming Languages: PHP:
What does this do? Can it work?

 



Merlin
journeyman

Nov 27, 2001, 12:00 PM

Post #1 of 6 (21003 views)
What does this do? Can it work? Can't Post

I found a small PHP cart system and it uses the following line of code to upload pictures of products (on the admin side) :

exec("mv $image '$WebRoot/images/".$ItemID.".jpg'");

For now, it doesn't do anything and I can't find references or help on this. Is there something special required for this to work? Do I need to tell our hosting service to modify something in order for it to work? I don't get errors or anything weird when using this, it just doesn't do it's work... Thx!



Jasmine
Administrator

Nov 27, 2001, 4:07 PM

Post #2 of 6 (20998 views)
Re: What does this do? Can it work? [In reply to] Can't Post

I don't know PHP, but it looks like the statement is invoking the server's "move" command. It's trying to move $image to $WebRoot/images/.$ItemID.jpg





Merlin
journeyman

Nov 28, 2001, 6:28 AM

Post #3 of 6 (20994 views)
Re: What does this do? Can it work? [In reply to] Can't Post

I thought so. But the thing is : can a move command on a server move a local file from the user to a server? This seems pretty weird... Thx for the info!



Kanji
User

Nov 28, 2001, 5:52 PM

Post #4 of 6 (20992 views)
Re: What does this do? Can it work? [In reply to] Can't Post

No, it can't.

Most likely, $image is the uploaded file; something PHP handles automatically if you've enabled the right things and have an entry like <input name="image" type="file"> in your form.

To me, the greater source of confusion is why the code is using exec() to move a file instead of the native rename() or move_uploaded_file() functions.

Anyhoo, for more information on PHP and uploads, see the manual.




Merlin
journeyman

Nov 30, 2001, 9:43 AM

Post #5 of 6 (20988 views)
Re: What does this do? Can it work? [In reply to] Can't Post

I forgot to mention that the PHP scripts I'm using are from 1999... PHP 3? Probably why this code looks weird...



pnolans
New User

Mar 6, 2007, 6:42 AM

Post #6 of 6 (20190 views)
Re: [Merlin] What does this do? Can it work? [In reply to] Can't Post

I know that this question is 5 years old. Anyway, mv is the command on Unix that renames files. In the process of renaming, of course, you can move a file.

Can you do it to a remote server? I don't think so.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives