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
https://forums.phpfreaks.com/topic/28705-upload-picture/
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
https://forums.phpfreaks.com/topic/28705-upload-picture/#findComment-131426
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
https://forums.phpfreaks.com/topic/28705-upload-picture/#findComment-131438
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
https://forums.phpfreaks.com/topic/28705-upload-picture/#findComment-131449
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
https://forums.phpfreaks.com/topic/28705-upload-picture/#findComment-131456
Share on other sites

lol well i didn't really notice it, but i think something inside of me is exicited about both.

i already make galleries and websites, but i wasn't working programing for a while and felt like coming back so i'm trying to ge tthe hang of it..
i guess i'll say both. :)
Link to comment
https://forums.phpfreaks.com/topic/28705-upload-picture/#findComment-131464
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.