Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Fukushousha

  • Rank

Contact Methods

  • MSN
  • Website URL

Profile Information

  • Location
    Thessaloniki , Greece
  1. Ho! That worked very nice. Deirdre's dad that is what I did. Just stored it in xml so I could edit it easily and have some form of knowledge database, since the forms represent knowledge.My problem was solved by justsomeguy's very simple remark. I had no idea that <form ..... action="" .... > equals <form ..... action="<?php $_SERVER['PHP_SELF']?>" .... > . What I wanted to do worked now. Thanks!
  2. Yeah I know it is server side but I thought that it could work like that. Hm ... can anyone think of a workaround for this? Any way to both dynamically create the forms and be able to call the whole php script again whenever the php submit button is pressed?
  3. Hello all.I have a problem. Up to now the calls to $_SERVER['PHP_SELF'] worked like a charm in any form in my website. Now I made something like ... a dynamic form generation. I am making the various forms by use of Javascript.LAter the javascript function is called inside a php script. Example of .js script: function fillSetArt(div){ //we load the XML file into xmlAudioObj xmlArtObj = loadXML(xmlArtObj,'artsoft.xml'); //this will be the function which will read the file and extract the data we need! xmlArtObj.onreadystatechange = function() { var text = '<form name="userSkills" id="userSkills" action="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">'; I added the form's declaration and well .. everything inside a javascript script which edits the inner html attribute of the DIV which I want to contain the various forms. The problem is that when I do it this way I get :Access forbidden!You don't have permission to access the requested object. It is either read-protected or not readable by the server.If you think this is a server error, please contact the webmaster.Error 403localhost06/18/08 11:23:07Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5And in the browser I can see that the error is thrown due to the PHPSELF call. Any idea how to get around this error?
  4. Yeah I know the $_FILES['file']['type'] but I was reluctant to use it because of the post I linked by someguy in my post above. Anyway I will figure something out. Thanks for the advice people
  5. I used this method because that is what I understood from this post by someguy.And yes I do realize there are too many formats out there >_< It would be 100% simple to tell them I accept only these 3 and that's that. Would that be bad? I am tempted to do so.
  6. Hello,A really quick question to which I just can't find the answer. Basically with my fetch user image I get the image type from the DB (which is stored by looking at the extension) and then give out the appropriate header like that : switch($imagetype){ case ".jpg": header("content-type: image/jpeg"); break; case ".gif": header("content-type: image/gif"); break; case ".png": header("content-type: image/png"); break; default: die("Something is really wrong if you get here.You got no imagetype from the DB");} My question is .. okay ... but what for all other image formats. I actually had forgotten them because I saw only these 3 headers. What should I do with all the other image types?
  7. Sorry for re-bumping my post but I finally managed to solve it. I would like to include the solution in this post since other people might find themselves in my situation. So ... here goes:I tried running the form standalone to see if $_FILES got written. It actually did!So the problem was code-related and not configuration. In my code another php script was included. It was login.php.Login.php contained 2 more forms. As one would expect of a login script ofcourse. I spent the last 2 days searching for empty $_FILES reasons so I learned many different reason why this would happen. One of those was that if you have more forms in the same file with your file upload form you have to add the enctype="multipart/form-data" attribute in them too. I just did that and it works now. So yeah ... ahem ... what can I say? I feel stupid for what I went through the last 2 days to find this. Even installing a different apache/php/mysql bundle .... *sigh*At least now it works. Hope this post can help anyone having the same problem and even help people avoid it in the future.
  8. I am really sorry for bumping my own post but this is ridiculous. I completely uninstalled EasyPhP and saved all of my work in a separate file. I downloaded the XAMPP php/apache/mysql bundle and installed it. Then moved all of my work in the new server, re-made all of my configurations and was good to go.I really thought that it would work. BUT NO! Still ... $_FILES is empty after uploading. I don't know what to do anymore. This was like the last resort ... and it did not work.I am including the whole .php file for which I am talking about ( the one where the user file upload form is ): <?php session_start(); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/mainSiteTemplate.dwt.php" codeOutsideHTMLIsLocked="false" --><head> <!-- InstanceBeginEditable name="headerstuff" --><title>Settings</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="/CSS/mainStyle.css" rel="stylesheet" type="text/css" /><link href="/CSS/profileStyle.css" rel="stylesheet" type="text/css" /><link href="/CSS/settingsStyle.css" rel="stylesheet" type="text/css" /><script type='text/javascript' src='animateScript2.js'></script><!-- InstanceEndEditable --></head><body><div id="pageLogo"></div><div id="pageHead"></div><div id="leftMenu"> <?php//With the page loading we make sure we instantiate a GLOBAL sql connection objectinclude ('sqlConnection.php');global $sql;$sql = new sqlConnection("localhost", "XXXX", "XXXX");include("login.php");displayLogin(); ?></div> <div id="tabMenu"> <ul> <!-- CSS Tabs --><li id="current"><a href="index.php"><span><h1>Home</h1></span></a></li><li><a href="register.php"><span><h1>REGISTER</h1></span></a></li><li><a href='#'><span><h1>USERS</h1></span></a></li><li><a href='#'><span><h1>PROJECTS</h1></span></a></li><li><a href='#'><span><h1>ABOUT</h1></span></a></li> </ul> </div><div id="centerOfPage"><!-- InstanceBeginEditable name="head" --><?phperror_reporting(E_ALL);global $sql;//if no user is logged in then .. do now allow to edit setting ofcourseif(!isset($_SESSION['username'])) echo"You are not logged in. Please log in or register first";else{ //get the user who is logged in now! $username = $_SESSION['username']; $resArray = $sql->selectUser($username); //if the user has not uploaded an image for himself show the default if($resArray['userImage'] == null) { ?> <div id="userImage"> </div> <?php } else {//else .. show the image he uploaded ?> <div id="userImage"> <img src="getUImage.php?usname=<?php echo($username);?>" /> </div> <?php } ?> <div id="imageEdit"> <!--The small form to submit a user image,if it is used refresh the settings page--> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> Want to change your picture?<input type="file" name="userpic" id="userpic" /> <input name="subpic" type="submit" value="Upload New Picture" /> </form> <?php eleos();?> </div> <?php}?> <!-- InstanceEndEditable --></div></body><!-- InstanceEnd --></html><?phpfunction eleos(){//if the user clicks the submit picture buttonif(isset($_POST['subpic'])){ //phpinfo(1); print_r($_FILES); }}?> And also the new php.ini part for the file uploading which I ofcourse checked if it is okay. ;;;;;;;;;;;;;;;;; File Uploads;;;;;;;;;;;;;;;;;; Whether to allow HTTP file uploads.file_uploads = On; Temporary directory for HTTP uploaded files (will use system default if not; specified).upload_tmp_dir = "C:\xampp\tmp"; Maximum allowed size for uploaded files.upload_max_filesize = 32M I tried escaping the 2 slashes the tmp dir which would have caused a problem if I typed it as a path. Specifically \t and \x butit did not work. Seems that php must do that automatically when reading where the server's tmp path is.
  9. Quoting from the php manual about headers.
  10. Since it is in another script just save the value of the form script and use a php header to redirect.If your problem is the header syntax then here you can get more info.
  11. Yeah you are right. I should have seen that tab. Anyway, with that gone I still get an error, only this time as you predicted a permission denied one.BIG EDIT:Well ... I was wrong. I was still sleepy and did not write the path correctly. No ... that was not the problem. I can create a file in that directory. So, it can't be because php can't write in the servers tmp directory since it actually can.Damn ... still at point one.
  12. I had tried uploading various sizes of files ... all were "Done" in an instant, even though I am operating on a local server, still it is not normal.BUT I think we might have something with the last thing you said. I just commented everything out from the previous part of code I was working on and put this : if(isset($_POST['subpic'])){ //the temporary file server directory //might use this as a global somewhere later //HAVE TO CHANGE FOR UPLOADING THE SITE IN A WEB SERVER //$tempdir = 'C:\Program Files\EasyPHP 2.0b1\tmp'; //phpinfo(1); file_put_contents("C:\eleos.txt","eleos re paidia");............... This works. No matter where I put it.BUT If I change it to file_put_contents("C:\Program Files\EasyPHP 2.0b1\tmp","eleos re paidia");this is what I get : Warning: file_put_contents(C:\Program Files\EasyPHP 2.0b1 mp) [function.file-put-contents]: failed to open stream: Invalid argument in C:\Program Files\EasyPHP 2.0b1\www\settings.php on line 112 Not to mention nothing is written in the temp folder. That must be it! Php can't write to that file ... but how come I did not get that error warning when I used the file form? Moreover ... how do I overcome this discrepancy? I tried changing the temporary server file from php.ini but nothing happened :/Anyhow it is becoming late here in greece and tomorrow I got SQL exams so I 'd better catch some sleep. Thanks again and will check for replies tomorrow!
  13. Thanks for trying to help justsomeguy. I really appreciate it. Unfortunately thought that wasn't it. My php.ini was already configured like that except from the display_startup_errors setting which was set to off. Even with that set to on though I still get no error.It's as if I never click the file upload button.
  14. Yeah that is what I was saying too. I had similar code, a little more complicated but ... for testing's sake I tried it like that too. Still $_FILES is an empty array.Unfortunately I can't think of anything else. Something must be wrong with my whole installation? I used easyphp to install php, apache and MySQL. But up to now (everything else apart from file uploading) it worked fine!
  15. I will do that with the php.ini thanks for the info!As for the form I can't see what can be wrong with it. I had posted it in the previous topic too. Here it is again: <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> Want to change your picture?<input type="file" name="userpic" id="userpic" /> <input name="subpic" type="submit" value="Upload" /> </form> All I do somewhere later is check if the subpic is set at the $_POST array and if it is so I am trying to retreive $_FILES['userpic']['name] which returns an undefined index userpic.And the $_FILES array is empty.
  • Create New...