download & upload script not to and from database – PHP

  php

Q(Question):

I have a page (html&php)from this page post this action to
<form method=post action="loadfile.php" ENCTYPE="multipart/form-data
well the loadfile.php is a script for upload file to the mysql data base and this is the code for loadfile.php

<?php $fold=$_REQUEST['fname'];$title=$_REQUEST['title'];$uploadedfile=$_REQUEST['uploadingfile']; $host="localhost";$user="";$pass="";$dbid="upload";$link=mysql_connect($host,$user,$pass);mysql_select_db($dbid); $path="hi/". $_FILES['uploadingfile']['name'];echo $path; move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path); mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')"); mysql_close($link); ?><?php
$fold=$_REQUEST['fname'];
$title=$_REQUEST['title'];
$uploadedfile=$_REQUEST['uploadingfile'];
$host="localhost";
$user="";
$pass="";
$dbid="upload";
$link=mysql_connect($host,$user,$pass);
mysql_select_db($dbid);
$path="hi/". $_FILES['uploadingfile']['name'];
echo $path;
move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path);
mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')");
mysql_close($link);
?>

i want to change this code and make it upload to folder like (my upload
) on the hard disk folder’s (www)

in the same thing i want to make download to my hard disk from new file named (mydownload) and this is folder existing where (appserv) already installed (www) folder

i hope to accept my best regards and best wishes

A(Answer):

want to change this code and make it upload to folder

Is it not a simple case of changing $path

move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path);

Not sure what you mean here

in the same thing i want to make download to my hard disk from new file named (mydownload) and this is folder existing where (appserv) already installed (www) folder

But it sounds like you will need FTP functions

A(Answer):

thank u code green to replay and i hope u to continue with me

my question is : what the loadfile.php cotained and how i can to write the right
script that make this operation,,,,

my second question was : i have hyperlink for download and when click on the hyperlink download started not to data base but to any place on my computer and then showed to some description about the file like (size,type,name)

A(Answer):

what the loadfile.php cotained and how i can to write the right
script that make this operation

PHP has good file operation functions. file_get_contents() will read a file to a string which is the simplest way to output to a browser

i have hyperlink for download and when click on the hyperlink download started not to data base but to any place on my computer

To move a file you simply rename it with

rename (string $oldname,string $newname)

A(Answer):

thank you code green to reply again

but please my question was :

<?php $fold=$_REQUEST['fname'];$title=$_REQUEST['title'];$uploadedfile=$_REQUEST['uploadingfile']; $host="localhost";$user="";$pass="";$dbid="upload";$link=mysql_connect($host,$user,$pass);mysql_select_db($dbid); $path="hi/". $_FILES['uploadingfile']['name'];echo $path; move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path); mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')"); mysql_close($link); ?><?php
$fold=$_REQUEST['fname'];
$title=$_REQUEST['title'];
$uploadedfile=$_REQUEST['uploadingfile'];
$host="localhost";
$user="";
$pass="";
$dbid="upload";
$link=mysql_connect($host,$user,$pass);
mysql_select_db($dbid);
$path="hi/". $_FILES['uploadingfile']['name'];
echo $path;
move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path);
mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')");
mysql_close($link);
?>

that scrip exist in the loadfile.php and that script let me upload the files from my page on (loacalhost) to mysql,,,,
how i can change it and make it upload not to mysql but to other place like(new folder on desktop)

A(Answer):

how i can change it and make it upload not to mysql but to other place like(new folder on desktop

Well I have already suggested FTP and rename().
What do you mean be ‘change it’.

A(Answer):

thank u it’s it is clear right now

LEAVE A COMMENT