PHP - Client - Side Uploading Problem
We have a website that allows the user to upload his/her picture so we use the ftp_put() command.
I use Code: [Select] <?php $path = getcwd(); echo $path; ?> This is the output: Code: [Select] /home/vol10/000a.biz/a000b_7363341/htdocs/gankgame to determine the absolute path where my website is stored. My website "CAN" connect to the ftp server but it can't upload files. Uploading always fail. I can't determine the right path. "My code is attached" Similar TutorialsI have a web portal which is scripted using client side scripting language i.e HTML. I want to create a login page in .php and want the other pages to be in .hmtl. Can i do so? I want to do this because i want the login password to be stored in a database. Also I want the password to get encrypted (by either MD5 javascript or OpenSSL ) when user enters it inside the login form. I cannot create the entire portal in php because my portal makes use of C code. And php doesn't have an interface with C language. Can a user get directed to a .html page after a secure login from login.php page ? My main aim is to secure the access to my web portal using a password. I tried to authenticate the login using javascript where the password was stored in an array. But i feel any one having moderate knowledge can easily break that password. Any help would be greatly appreciated!! is it true that all the server side code runs before the client side code when accessing a webpage? if that is true, what about PHP code that is embedded inside HTML tags? wouldn't that result in an error a lot of times? I wish to create validation rules once which are used both on the client and on the server.
For instance, I will start off with the following PHP object:
stdClass Object ( [rules] => stdClass Object ( [email] => stdClass Object ( [required] => 1 [email] => 1 [remote] => stdClass Object ( [url] => check-email.php [type] => post [data] => stdClass Object ( [username] => function() {return $( '#username' ).val();} ) ) ) ) [messages] => stdClass Object ( [email] => stdClass Object ( [required] => an email is required ) ) )When the edit page is downloaded to the client, I will include this object in some format suitable to the client. The client will then use the jQuery Validation plugin (http://jqueryvalidation.org/) along with the validation object, and client side validate the page. When the form passes client side validation and is uploaded, PHP will use the same validation object to serverside validate the form (I have this part working as desired). My question is how should I pass this data to the client? Originally, I would just use PHP to write some JavaScript. exit('var myObj='.json_encode($myObj));Note that when I json_encode the object, the value of $myObj->rules->email->remote->data->username is a string with quotes around it, however, I can easily use PHP to strip these tags before sending it to the client. As Jacques1 pointed out in http://forums.phpfre...ascript-client/, I should never ever use PHP to generate JavaScript, and should use AJAX to download the JSON directly. I tried doing the later, but found that a callback function could not be included in the JSON. Please advise on the best way to accomplish this. Thank you Hello guys. I was thinking on posting this under the mysql thread. but i think this can be solved by php.. anyway, i want to dump mysql data on the client side whenever a user logs out. how can i do this? thanks in advance. I'm in the habit of verifying input client side. For example, there is a field to enter a number, and I ensure that it is within a particular range using Javascript. My backend PHP code does not do such checking... Is this bad? Should I be doing checking using my backend code and send a response back to the client to display a message? Admittedly, I avoid it, since it's a little extra work -- well more extra than just javascripts, IF-THEN-ALERT type statement. I was wondering about developing simple client side graphical apps.
I was thinking of using php with an ODBC connection to the data store.
The data store might be a text file in CSV format or something similar. (maybe even a spreadsheet)!
I was wondering what would be a very simple minimally useful web server to run on the client?
The client would probably be MS Windows XP/7.
What are your thoughts?
I want to do simple client side validation but I don't know Javascript. Can someone point me to an easy example on how to implement or post something here? Is it possible adding a button with PHP, which could be used for adding an optional text input field by client side user? My purpose is actually very simple: The client side users could be free creating and adding more and customized variables, which are intended to be used as strings and related or associated variables. So, am I able to do these kind of tasks simply using PHP alone? Or, should I use some JavaScript like technologies to make those functions available in real world's practices? Hi All - I'm trying to see if the below is possible using PHP. is it possible for php to allow a user to check if a port is open/listening on a remote server/PC, from their local machine. I've seen scripts on the web that talk about opening cmd.exe - this won't work as not all of my users will be on windows. Also saw fsock.. but the remote server is not serving http page(s). Also saw telnet, but again, some of my users may not have that windows feature enabled. Desired workflow: 1. user enters the server hostname/IP and a port 2. my php webapp will emulate checking if that hostname and port is open from the local user's computer.
thanks! hi guys... I'm resizing image with some script. it works fine. but some times it gives following error and make image black. either it should not upload/resize image or it should do that for all. following is the error list i found on some images Code: [Select] Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/large/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/thumb/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/medium/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/xlarge/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 I am having trouble getting my upload file to work... Form HTML: Code: [Select] <form action="" method="POST"> <input type="file" name="file" /> <input type='"submit" name="upload" value="Upload" /> </form> PHP: Code: [Select] if($_POST["upload_avatar"]){ $upload_path = "images/users/"; $file = $_FILES["file"]["name"]; $extension_types = array("gif","jpg","jpeg","png"); if($file){ $filename = stripslashes($_FILES["file"]["name"]); $extension = getExtension($filename); $extension = strtolower($extension); $size = filesize($_FILES["file"]["tmp_name"]); if(in_array($extension, $extension_types)){ if($size <= $max_file_size){ $file_search = glob($upload_path . strtolower($username) . '*'); array_map("unlink", $file_search); $file_name = $upload_path . strtolower($username) . "." . $extension; $copied = copy($_FILES["file"]["tmp_name"], $file_name); if (!$copied){ $r_error = "Upload has failed"; } } else{$r_error = "File too big";} } else{$r_error = "Unknown file extension";} } else{$r_error = "No file chosen";} } Every time, it gives me the "No File Chosen" error. It doesn't seem to be actually uploading the file... I hope this isn't just some stupid thing I am looking over, can someone help me? This is my PHP code which uploads the image from a html form. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Upload a Photograph</title> <link rel="stylesheet" href="uploadify.css" type="text/css" /> <script language="JavaScript" type="text/javascript"> <!-- function breakout_of_frame() { // see http://www.thesitewizard.com/archive/framebreak.shtml // for an explanation of this script and how to use it on your // own website if (top.location != location) { top.location.href = "http:/noltest.lib.siu.edu/drupal/blincore?file='"+fileObj.name+"'" ; } } --> </script> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery.uploadify.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#fileUpload").fileUpload({ 'uploader': 'uploader.swf', 'cancelImg': 'cancel.png', 'script': 'upload.php', 'folder': 'downloads', 'fileDesc': 'Image Files', 'fileExt': '*.jpeg,*.jpg,*.tif,*.tiff,*.gif,*.png', 'checkScript': 'check.php', 'multi': false, 'displayData': 'speed', 'onComplete': function(event, queueID, fileObj, response, data) { $('#filesUploaded').append ('One Image Uploaded successfully (<a href='+fileObj.filePath+'>'+fileObj.name+'</a>)</br></br> <FORM METHOD=POST ACTION="http://nol.lib.siu.edu/drupal/dublincore"> <INPUT NAME=filename value="'+fileObj.name+'"> <INPUT TYPE=submit VALUE="NEXT" ></FORM ><br>');} }); }); </script> </head> <body style="background: #f1ede0 url(http://nol.lib.siu.edu//sites/all/themes/admire_grunge/images/bg2.jpg) repeat fixed top center;"> <h2>Single Photograph Upload</h2> <div id="fileUpload">Issue with your javascript</div> <a href="javascript:$('#fileUpload').fileUploadStart()">Start Upload</a> | <a href="javascript:$('#fileUpload').fileUploadClearQueue()">Clear Queue</a> <p></p> <p><div id="filesUploaded"></div></p> </body> </html> problem: when i try to upload image from the desktop which contains image named (test.jpg) , this test.jpg is not shown when browsing to select the image file. any advice... Hi, I have a strange problem with uploading files. My script was working fine on the test server but since moving to the live server it isn't working. Here is a printout of the FILES variable: Code: [Select] Array ( [file] => Array ( [name] => filename.ppt [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) Does anyone know what the problem might be? The error message that comes back is 'Invalid file'. Code: [Select] function upload_ppt_files() { echo 'print_r($_FILES) = '.print_r($_FILES).'<br />'; global $CFG; if (($_FILES["file"]["type"] == "application/vnd.ms-powerpoint") && ($_FILES["file"]["size"] > 100)) { if ($_FILES["file"]["error"] > 0) { $CFG->message = "Error code:". $_FILES["file"]["error"]; manage_ppt_files(); } else { if (file_exists("../../uploads/" . $_FILES["file"]["name"])) { $CFG->message = $_FILES["file"]["name"] . " already exists."; manage_ppt_files(); } else { move_uploaded_file($_FILES["file"]["tmp_name"], "../../uploads/" . $_FILES["file"]["name"]); $CFG->message = "File uploaded successfully."; manage_ppt_files(); } } } else { $CFG->message = "Invalid File."; manage_ppt_files(); } } Hi All, I have been having issues for several days uploading a simple pdf file via Curl to one of our service providers servers. I'm doing an is_uploaded_file check and getting a successful response, but the document is not actually being uploaded to the server. Can anyone help?? Please see code below: Code: [Select] $filename = $_FILES['activity_doc']['name']; // Name of the file (including file extension). $upload_path = https://upload_url //Curl session initialized $session = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($session, CURLOPT_URL, $upload_path); curl_setopt($session, CURLOPT_USERPWD, 'username:password'); curl_setopt($session, CURLOPT_POST, 1); $post = array( "file_box"=>"@" . $filename, ); curl_setopt($session, CURLOPT_POSTFIELDS, $post); $response = curl_exec($session); if (is_uploaded_file($_FILES['activity_doc']['tmp_name'])) { echo "File ". $_FILES['activity_doc']['name'] ." uploaded successfully.\n"; } else { echo "Error occurred, file uploaded unsuccessful"; } $req = new SimpleXMLElement($response); print_r($req); curl_close($session); hi, i am working on an assignment in which i am getting current date and then getting date of two previous months i.e 2010-09 2010-08 2010-07 the problem is that the code is working perfectly on localhost but when i upload the file it only shows the current date and do not subtract and display dates. can some body guide me that what is the problem and how to solve it. here is the code $date1= date("Y-m"); $date2 = strtotime ( '-1 month' , strtotime ( $date1 ) ) ; $date2 = date ( 'Y-m' , $date2 ); $date3 = strtotime('-1 month', strtotime( $date2 ) ); $date3 = date( 'Y-m' , $date3); ?> <select name=""> <option><?php echo $date1; ?></option> <option><?php echo $date2; ?></option> <option><?php echo $date3; ?></option> </select> I developped a cms system to upload images with php to a mysql database and a upload folder on the server. Firefox version 5.0.1 for MAC and earlier have no problems with uploading through the script. But after that version it is impossible to upload images bigger then 250kb. The page where the customer chooses his image for upload stalls and the form is not sent to the actual upload script, which should validate and process the image. This problem only occurs in Firefox, all other browsers work just fine! I tried to run the same script with Firefox on a PC and everything works fine. So it is a Mac related problem. You can try for yourself to see what happens in the following basic script (if you don't get a succes message it means that you are still hanging on the image_upload page and nothing has happened) : http://siteways.net/test_upload/image_upload.php hi i m new to php there is two basic script i m testing on my localhost but it gives me error "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 4" "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 16" "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 27" i cant find where is the real problem is ##########FORM########### <form name="upload" action="upload.php" method="POST" enctype="multipart/form-data"> <input type="file" name="video"> <input type="submit" value="UPLOAD"> </form> #########FORM############ #########PHP############# <?php // This is the directory where images will be saved $path="uploaded/"; $path=$path.basename($_FILES["video"]["name"]); //This gets all the other information from the form $video=$_FILES["video"]["name"]; //connect to database $con=mysql_connect("localhost","root","") or die (mysql_error()); //SELECTING THE DATABASE mysql_select_db("admin_bj",$con) or die(mysql_error()); //write information to the database mysql_query("INSERT INTO 'video'(video) VALUES('$video')"); //write file to server if(move_uploaded_file($_FILES["video"]["tmp_name"],$path)) { // execute if all is ok echo "the file " . basename( $_FILES['uploadedfile']['name']). "has been uploaded and your information has been added to the server"; } else { //GIVES AND ERROR IF ITS NOT OK echo "Sorry,there was a problem in uploading."; } ?> #########PHP############# |