upload picture

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

upload picture

Post by corillo181 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


why isn't this code working?

Code: Select all

<?php
if(isset($_POST['Submit'])){

$dir='image/';
$filename = $_FILES['ulfile']['name'];
$random = rand(0,9999999999);
$pos = strrpos($filename, '.');
$newname = $random . substr($filename, $pos);
$tmpname = $_FILES['ulfile']['tmp_name'];
$filesize = $_FILES['ulfile']['size'];
$filetype = $_FILES['ulfile']['type'];
$datetime = date('m-d-y h:i:s');
$filepath = $dir . $newname;
$result=copy($tmpname, $filepath);
if(!$result){
echo "not done";
}
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There's probably something wrong.
iluxa
Forum Newbie
Posts: 15
Joined: Wed Nov 29, 2006 3:29 am

Post by iluxa »

What errors are you getting?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

I'm going to take a wild guess ... images/ isn't set as writable.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Do you have the following property defined in form tag ? Most of the time, we forget to put this property.

Code: Select all

enctype="multipart/form-data"
If yes, to debug the code, just print the array $_FILES first.

Code: Select all

print_r($_FILES);
This will help you debug quickly.

With Regards,
Dibyendra
Post Reply