By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,937 Members | 1,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,937 IT Pros & Developers. It's quick & easy.

download & upload script not to and from database

P: 6
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
Expand|Select|Wrap|Line Numbers
  1. <?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
  2.  
  3. $fold=$_REQUEST['fname'];
  4. $title=$_REQUEST['title'];
  5. $uploadedfile=$_REQUEST['uploadingfile'];
  6.  
  7. $host="localhost";
  8. $user="";
  9. $pass="";
  10. $dbid="upload";
  11. $link=mysql_connect($host,$user,$pass);
  12. mysql_select_db($dbid);
  13.  
  14. $path="hi/". $_FILES['uploadingfile']['name'];
  15. echo $path;
  16.  
  17. move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path);
  18.  
  19. mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')");
  20.  
  21. mysql_close($link);
  22.  
  23.  
  24. ?>
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
Apr 6 '10 #1

✓ answered by code green

want to change this code and make it upload to folder
Is it not a simple case of changing $path
Expand|Select|Wrap|Line Numbers
  1. 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

Share this Question
Share on Google+
6 Replies


code green
Expert 100+
P: 1,726
want to change this code and make it upload to folder
Is it not a simple case of changing $path
Expand|Select|Wrap|Line Numbers
  1. 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
Apr 7 '10 #2

P: 6
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)
Apr 7 '10 #3

code green
Expert 100+
P: 1,726
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
Expand|Select|Wrap|Line Numbers
  1. rename (string $oldname,string $newname)
Apr 8 '10 #4

P: 6
thank you code green to reply again

but please my question was :
Expand|Select|Wrap|Line Numbers
  1. <?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 
  2.  
  3. $fold=$_REQUEST['fname']; 
  4. $title=$_REQUEST['title']; 
  5. $uploadedfile=$_REQUEST['uploadingfile']; 
  6.  
  7. $host="localhost"; 
  8. $user=""; 
  9. $pass=""; 
  10. $dbid="upload"; 
  11. $link=mysql_connect($host,$user,$pass); 
  12. mysql_select_db($dbid); 
  13.  
  14. $path="hi/". $_FILES['uploadingfile']['name']; 
  15. echo $path; 
  16.  
  17. move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path); 
  18.  
  19. mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')"); 
  20.  
  21. mysql_close($link); 
  22.  
  23.  
  24. ?>
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)
Apr 9 '10 #5

code green
Expert 100+
P: 1,726
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'.
Apr 12 '10 #6

P: 6
thank u it's it is clear right now
Apr 13 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.