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


Nov 27, 2001, 12:00 PM

Views: 48815
What does this do? Can it work?

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!


Nov 27, 2001, 4:07 PM

Views: 48810
Re: What does this do? Can it work?

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


Nov 28, 2001, 6:28 AM

Views: 48806
Re: What does this do? Can it work?

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!


Nov 28, 2001, 5:52 PM

Views: 48804
Re: What does this do? Can it work?

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.


Nov 30, 2001, 9:43 AM

Views: 48800
Re: What does this do? Can it work?

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

New User

Mar 6, 2007, 6:42 AM

Views: 48002
Re: [Merlin] What does this do? Can it work?

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.