Jump to content


file upload trouble


3 replies to this topic

#1 ap_

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 06 April 2008 - 12:33 AM

the code returns the random name but dont know why does not store it where its supose to.

this is the code and thanks by the way!

<?php
function uploadform($enable){

if($enable == true){

 print('<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
Choose a file to upload: <br /><input name="upfile" type="file" />
<input type="submit" name="upload" value="Upload" style="height: 20px; font-size: 12px;"/>
</form>');

}else{

print('the service has been disable. Should be back shortly!');

}
}

if(!isset($_POST['upload'])){

print uploadform(1);

}else{

$filenm = basename($_FILES['upfile']['name']);
$ext = basename($_FILES['upfile']['type']);
$rand = rand(0000,9999);
$randname = $rand.$filenm;
$target = "files/".$randname;


$qry = move_uploaded_file($_FILES['upfile']['tmp_name'],$target);
if(!isset($qry)){
echo('error');
}else{
echo($randname);

}

}

?>


#2 fycnrdths

    Young Padawan

  • Members
  • Pip
  • 16 posts
  • Location:stuck to my desk chair
  • Interests:programming.

Posted 06 April 2008 - 12:47 AM

For starters, try replacing this:

Quote

$qry = move_uploaded_file($_FILES['upfile']['tmp_name'],$target);

with this:
move_uploaded_file($_FILES['upfile']['tmp_name'],$target);
 echo($randname);

You can also use this site for reference:
http://www.w3schools...file_upload.asp

#3 ap_

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 06 April 2008 - 01:09 AM

i tryied but stil dont storeit where i put it thank anyway im gona chek out the link thanks.

#4 ap_

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 06 April 2008 - 03:03 AM

this one does work and have a size restriction tool
hope could be usefull for some one.
thanks for the guy who answer my post it was that a forget about the error reporting of the php ini
<?php


function uploadform($enable){
if($enable == true){
print('<form enctype="multipart/form-data" method="POST">
Selecciona un archivo a almacenar: <br />
<input name="upfile" type="file" />
<input type="submit" name="upload" value="Upload" style="height: 20px; font-size: 12px;"/>
</form>');
}else{
print('El servicio a sido temporeramente desactivado!');
}
}



if(!isset($_POST['upload'])){
	print uploadform(1);
}else{



$filenm = basename($_FILES['upfile']['name']);
$ext = basename($_FILES['upfile']['type']);
$size = basename($_FILES['upfile']['size']);
$rand = rand(0000,9999);
$randname = $rand.$filenm;
$target = "bin/files/".$randname;




if($size >= 10385760){
print('El archivo es demasiado grande! buelva a intentar.');
return false;
}


$qry = move_uploaded_file($_FILES['upfile']['tmp_name'],$target);
if(!isset($qry)){
	print('error');
}else{
	print($randname);
}

}

?>






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users