Jump to content

upload picture


corillo181

Recommended Posts

why isn't this code working?

<?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";
}
}
?>
Link to comment
Share on other sites

[quote author=corillo181 link=topic=116550.msg474953#msg474953 date=1164695159]
<form action="ul.php" method="post" enctype="multipart/form-data" name="ul" id="ul">
<input type="file" name="imagefile">

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




sorry this is the firs tpart of the code
[/quote]

$_FILES['ulfile'] ... <input type="file" name="imagefile">

Match em up ^.^?
Link to comment
Share on other sites

[code]<form action="ul.php" method="post" enctype="multipart/form-data" name="ul" id="ul">
<input type="file" name="ulfile">

<input type="submit" name="Submit" value="Submit">
</form>
[/code]


[code]<?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";
}
}
?>
[/code]

i still get the not done..
Link to comment
Share on other sites

it worked for me :X it was named a string of numbers for the filename though, only change I made for my server was change $dir to match my directories... I had it all in one page

ul.php....

<form action="ul.php" method="post" enctype="multipart/form-data" name="ul" id="ul">
<input type="file" name="ulfile">

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

[code=php:0]<?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";
}
}
?>[/code]
Link to comment
Share on other sites

It works fine for me even if they are seperate....

IF your form is in like...
htdocs/uploadform.php

and your upload script is in like...
htdocs/scripts/ul.php

then you would need to do absolute directory listing to where you want to upload to (in your $dir string)
eg...
/home/local/apache2/htdocs/image/

This obviously is so because it's trying to upload to...
htdocs/scripts/image/
and that probably doesn't exist....


Another alternative is you didn't chmod 777 your upload directory?


Trying to go through all the alternatives.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.