Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2003, 09:21 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default php uploading

okay, I've got me hands on a little bit of code to upload a file ive submitted with a form, which looks something like this :

Code:
if ($img1_name != "") {
        @copy("$img1" , "/home/admin/www/fileupload/$img1_name") 
                or die("Couldn't Upload Your File.");
} else {
       die("No File Specified");
}
I then modified it, with the intention to change the directory i was uploading to, not knowing my whole path, and also to assign a variable which would point to the image to be put into my database

Code:
if ($pic_name != "") {

        @copy("$pic" , $PHP_SELF."/imgs/") ;
                $pic_url = $PHP_SELF."/imgs/".$pic_name;
                $wasuploaded = "1";
}
the file got there okay (i can get name and size etc.) and APPANRENTLY it was uploaded (the $wasuploaded was true) but the copy command didn't seem to do anything.
What i do wrong?

 
Old July 29th, 2003, 09:34 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

You probably have a file permissions error.

Turn off the error surpression and see what its trying to tell you.

*Leave off the '@'*

Code:
copy("$img1" , "/home/admin/www/fileupload/$img1_name") 
                or die("Couldn't Upload Your File.");
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading images with PHP Adam H-W PHP How-To 1 May 30th, 2006 10:11 AM
PHP Warning: PHP Startup: Unable to load dynamic l surendran Beginning PHP 1 May 29th, 2006 08:49 AM
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
uploading PHP files Adam H-W Beginning PHP 1 January 20th, 2006 02:06 AM
Error: movie.php & commit.php on p182-186, ch6 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 12th, 2004 02:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.