lokie538 Posted December 31, 2008 Share Posted December 31, 2008 Hi, Ive been reading up on how to move a file through php coding. On some sites it says you can use the rename function or the copy + delete functions. I couldnt get either of these too work tho. Sorry about being a noob guys. I couldnt get this too work: <?php $file = fopen("Gallery\Large\3.jpg", "r"); $newfile = "Gallery\3.jpg"; copy($file, $newfile); ?> Any ideas why this wont work? or a code that would work? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/ Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 You would just use the paths, not the actual file. Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727033 Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 So it copies the content of the whole folder? Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727035 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 <?php $file = "Gallery\Large\3.jpg"; $newfile = "Gallery\3.jpg"; copy($file, $newfile); ?> That should do what you want. Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727037 Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 Warning: copy(Gallery\Large.jpg) [function.copy]: failed to open stream: Invalid argument in C:\wamp\www\1300 Face Painting\move.php on line 17 I get that error when I tried it :/ Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727039 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 Show the full code please. According to the copy manual that should work as long as the paths are correct. Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727042 Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 hmm this works: <?php $file = "Gallery\Large\apple.jpg"; $newfile = "Gallery\apple.jpg"; copy($file, $newfile); ?> Why would a 1 (or 3) make a difference? It does show this tho Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727044 Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 and yes 1.jpg did exist Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727045 Share on other sites More sharing options...
lokie538 Posted January 1, 2009 Author Share Posted January 1, 2009 hmm so what would be wrong with having 1.jpg? Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727309 Share on other sites More sharing options...
premiso Posted January 1, 2009 Share Posted January 1, 2009 No clue why 1 would be a problem. You could try adding an alpha character before it and see if it works. IE: a1.jpg b1.jpg or something similiar. Quote Link to comment https://forums.phpfreaks.com/topic/139011-solved-move-a-uploaded-picture-problem/#findComment-727495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.