954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to upload a file with out using input type file

HI , CAN ANY ONE TELL ME HOW CAN I UPLOAD A FILE TO MY WEB SERVER WITH OUT USING , I JUST WANNA USE I BUTTON TO UPLOAD A FILE , AND WHENEVER I CLICKED ON THAT BUTTON I WANNA A FILE WHICH IS ON MY SYSTEM c:/UPLOADFILE/ANY.TXT , SHOULD BE START UPLOADING ..... PLEASE HELP ME

peterpa
Newbie Poster
20 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

You can use FTP. You can link a button to an ftp script:

http://www.php.net/manual/en/function.ftp-put.php

However, there are a number of good flash-js-php uploaders out there like uploadify, which show upload progress.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

you are right Mr ardav ,i have already ftp upload but i wanna that file should be also on webserver , so in this i am getting problem that , if i am uploading form my machine than it woking fine but when same thing i am trying on my webserver , it creating error . i am showing you

// FTP access parameters
$host = 'ftp.mysite.in';
$usr = 'user@mysite.in';
$pwd = 'mysite@123';
 
// file to move:
$local_file = 'd:/3.png';
$ftp_path = '/3.png';
 
// connect to FTP server (port 21)
$conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
 
// send access parameters
ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
 
// turn on passive mode transfers (some servers need this)
// ftp_pasv ($conn_id, true);
 
// perform file upload
$upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);
 
// check upload status:
print (!$upload) ? 'Cannot upload' : 'Upload complete';
print "\n";
 
/*
** Chmod the file (just as example)
*/
 
// If you are using PHP4 then you need to use this code:
// (because the "ftp_chmod" command is just available in PHP5+)
if (!function_exists('ftp_chmod')) {
   function ftp_chmod($ftp_stream, $mode, $filename){
        return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
   }
}
 
// try to chmod the new file to 666 (writeable)
if (ftp_chmod($conn_id, 0644, $ftp_path) !== false) {
    print $ftp_path . " chmoded successfully to 666";
} else {
    print "could not chmod $file";
}
 
// close the FTP stream
ftp_close($conn_id);
peterpa
Newbie Poster
20 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Moving a file from place to place on the webserver probably needs 'copy()'. or if you want to move a file use 'rename()'. Is that it?

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

i am again telling you :
i wanna do that just one file which is in my computer location "D:/3.png". and wanna upload this file with out using input type file ..... please help me

peterpa
Newbie Poster
20 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 
if i am uploading form my machine than it woking fine but when same thing i am trying on my webserver , it creating error

THat suggested to me that upload from machine to webserver was fine, but trying from one area of the webserver to another was not.

Unless you use something like FTP, I can't see how you'd upload a file without input=file as this could be a severe security breach. You'd probably be relying on very low browser security settings. Not advisable.

So sorry, can't help you. Anybody else?

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: