Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-09-2003, 05:44 PM   #1 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
trouble with some image upload code

Hi,

So I got this codefrom phpfreaks.com, and it is supposed to work fine, it works for everyone else.
anyways what it is supposed to do is upload a gif to files/ but instead it just clears the text box. thats it. nothin is uploaded, no errors, just basically like a reset button.

i think the code is fine but here it is anyways:

PHP Code:
<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="imagefile">

<input type="submit" name="Submit" value="Submit">

<?
if(isset( $Submit ))
{

if (
$_FILES['imagefile']['type'] == "image/gif"){

    
copy ($_FILES['imagefile']['tmp_name'], "files/".$_FILES['imagefile']['name'])
    or die (
"Could not copy");

        echo 
"";
        echo 
"Name: ".$_FILES['imagefile']['name']."";
        echo 
"Size: ".$_FILES['imagefile']['size']."";
        echo 
"Type: ".$_FILES['imagefile']['type']."";
        echo 
"Copy Done....";
        }
        else {
            echo 
"";
            echo 
"Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")";
        }
}
?> </form>
anyways, could it be a problem with php.ini (i've been having a lot of trouble with that lately, lots of stuff turned off) or some other php/apache configuration file?

ideas?

thanks all!
trevor is offline   Reply With Quote
Old 02-09-2003, 05:59 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
a common problem for upload scripts is permissions.

make sure the directory you are uploading to has write permission for everyone. ( chmod 666 /somedirectory )
sde is offline   Reply With Quote
Old 02-09-2003, 06:14 PM   #3 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
but shouldn't it at least give me the error "could not copy"?
trevor is offline   Reply With Quote
Old 02-09-2003, 06:37 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
no, . i t just won't do it.

are you sure your permissions are set to 666? or in your ftp program, usually you can check the directory properties and make sure all 3 are set to write.
sde is offline   Reply With Quote
Old 02-09-2003, 06:47 PM   #5 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
the apache dir is all 666, is there any other dir I have to change?
trevor is offline   Reply With Quote
Old 02-09-2003, 07:17 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
you know what, .. now that i think about it, a directory has to be executable to view files inside of it.

try 777 ... but still, your file should upload with 666 i think.
sde is offline   Reply With Quote
Old 02-09-2003, 07:30 PM   #7 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
i origionally had it at 777, still no go. I tried it again and nothing.
trevor is offline   Reply With Quote
Old 02-09-2003, 07:33 PM   #8 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
i still dont see why it wouldn't still give me the error?
trevor is offline   Reply With Quote
Old 02-10-2003, 12:36 PM   #9 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
try:

PHP Code:
<?
move_uploaded_file
($_FILES['userfile']['tmp_name'], "$destination/".$_FILES['userfile']['name']);
?>
and make sure the destination directory is writeable by whichever user the php script is being executed as (probably 'nobody'). also, make destination an absolute pathname, just to be sure.
joe_bruin is offline   Reply With Quote
Old 02-10-2003, 02:40 PM   #10 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
uh, your form action is blank dude.

im pretty sure you need to put something in there.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 02-10-2003, 02:46 PM   #11 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
hehe , i can't believe i didn't see that either.
sde is offline   Reply With Quote
Old 02-11-2003, 07:09 AM   #12 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
har har.

you still coming down on saturday mike?
__________________


Urban Clothing
Admin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
image gallery code Umair MS Technologies ( ASP, VB, C#, .NET ) 0 09-10-2004 05:47 AM
Cisco Code breaking sde Code Newbie News 0 05-21-2004 07:10 AM
Microsoft probes Windows code leak redhead Code Newbie News 0 02-13-2004 12:41 AM


All times are GMT -8. The time now is 05:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting