Page 1 of 1

upload picture

Posted: Tue Nov 28, 2006 12:21 am
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]

Posted: Tue Nov 28, 2006 2:17 am
by volka
There's probably something wrong.

Posted: Wed Nov 29, 2006 3:58 am
by iluxa
What errors are you getting?

Posted: Wed Nov 29, 2006 4:46 am
by onion2k
I'm going to take a wild guess ... images/ isn't set as writable.

Posted: Wed Nov 29, 2006 5:40 am
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