Jump to content

jazzman1

Staff Alumni
  • Posts

    2,713
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by jazzman1

  1. Try, <?php $uploadpath = 'upl/'; // directory to store the uploaded files $max_size = 10000; // maximum file size, in KiloBytes $alwidth = 5000; // maximum allowed width, in pixels $alheight = 5000; // maximum allowed height, in pixels $allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) { $uploadpath = $uploadpath . basename( $_FILES['fileup']['name']); // gets the file name $sepext = explode('.', strtolower($_FILES['fileup']['name'])); $type = end($sepext); // gets extension list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']); // gets image width and height $err = ''; // to store the errors // Checks if the file has allowed type, size, width and height (for images) if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.'; if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.'; if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight; // If no errors, upload the image, else, output the errors if($err == '') { // this line checks if the file exist return (!file_exists($uploadpath.'.'.$type)) ? true : false; if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) { echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:'; echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>'; echo '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB'; if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height; echo '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>'; } else echo '<b>Unable to upload the file.</b>'; } else echo $err; } ?> <div style="margin:1em auto; width:333px; text-align:center;"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> Upload Image: <input type="file" name="fileup" /><br/> <input type="submit" name='submit' value="Upload" /> </form> </div>
  2. upl/ This is a directory not a file. Do you know what is different between a file and directory?
  3. What is that? $fn = 'upl/wildcard'
  4. Maybe, you have open more than one mysqli statements connection to the server, I don't know
  5. http://php.net/manual/en/function.file-exists.php You can run a javascript code and using an AjaxRequest to check if that particular file exist in web server directory. If the file exist return message, if doesn't exist proceed the server script in php and make the same if test but this time on the server side.
  6. Before to submit the form or after?
  7. I don't agree with you. Phpfreaks is a very useful and interesting forum. I think that's why, you are come back. I like the people like OP and don't like the people like these.
  8. @OP, there is a syntax error (maybe two or more) in your sql query. Instead using a date function in php, in that particular example you could use date-time functions in mysql. Also, why did you close mysql connection and then make a test for the correct result? Well, you need to obtain basic knowledge before to start using the script even like this.
  9. Yes, that's correct Now, every input field with attribute name from the form, it could be contain multiple values as array itself.
  10. I've made a simple test with a negative y-coordinate of source point value setting it to -200, and it works just fine. Here it is: <?php // Create image instances $src = imagecreatefromjpeg('images/12 Giulio Berruti picture.2.jpg'); $dest = imagecreatetruecolor(500, 800); // Copy imagecopy($dest, $src, 0, 0, 0, -200, 500, 800); // Output the image header('Content-Type: image/jpeg'); imagejpeg($dest,NULL, 90); // free from memory imagedestroy($dest); imagedestroy($src);
  11. Well, let's see the array and its indexes before to loop it. Above the foreach put it that: echo '<pre'>.print_r($info, true).'</pre>'; exit; $i = 0; foreach ($info as $file_info) { $all = explode(",",$file_info); $id = $all[$i]; $filename = $all[$i]; $url = $all[$i]; $filetype = $all[$i]; $filesize = $all[$i]; $db->query("INSERT INTO newsfeeder_files (fileId, originalFilename, shortUrl, fileType, fileSize) VALUES ('".$id."','".$filename."','".$url."','".$filetype."', '".$filesize."')"); $i++ }
  12. You had an error inside the input field. See, what result I got when I copy/paste the code to my NetBeans and open up in firebug: <input type="\"text\"" style="width:400px;" name="\"services\""> There was to much posting here, sorry about it
  13. Put it the value attribute to <input type="text" name="services" value="" /> for every case and try again.
  14. Ok , and now: echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />"; echo "</form>"; }else { // here echo '<pre>'.print_r($_POST['services'], true).'</pre>'; exit; $service = protect($_POST['services']);
  15. Ok, than, put it this line of code immediately after $service = protect($_POST['services']); submit the form and give me back the result: echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />"; echo "</form>"; }else { $service = protect($_POST['services']); // here echo '<pre>'.print_r($service, true).'</pre>'; exit;
  16. Sorry, it should be only: echo __FILE__;
  17. Put it this on the top of that script and give me the path name: EDIT: I am going to smoke echo realpath(dirname(__FILE__));
  18. And.... you posted the entire script?
  19. There is only 63 rows inside that particular file Are you sure that that file is called - admin-addservice.php?
  20. Which is the line 93?
  21. Ok, then! Put the error_reporting(-1) to the top of the file and tell us what error(s) do you get? Copy/Paste my script! Ops....there is no return $con in connect() function inside the add2.php file! function connect () { $con = mysql_connect("localhost", "root",'') or die(mysql_error()); $db = mysql_select_db("patient", $con); return $con; } <?php error_reporting(-1); include_once "add2.php"; connect(); if (!isset($_POST['submit'])){ echo "<form method=\"post\" action=\"admin-addservice.php\" name=\"Registration Form\">"; echo "<br/>"; echo 'Name of Service: ' . '<br/>' . '<input type=\"text\" name=\"services\" style="width:400px;"/>' . '<br/>' . '<br/>'; echo "Description: " . "<br/>"; //echo '<textarea cols="80" rows="10" name=\"description\" maxlength=\"1000\" style=\"overflow: hidden;\">'; //echo '</textarea>' . '<br/>' . '<br/>'; echo "<input type=\"text\" name=\"\">"; echo "Price: " . '<br/>'; echo "<input type=\"text\" name=\"price\" style='width:200px;'/>" . '<br/>'; echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />"; echo "</form>"; }else { $service = protect($_POST['services']); $description = protect($_POST['description']); $price = protect($_POST['price']); $errors = array(); if(!$service) { $errors[] = "Invalid Name of Service!"; } if(!$description) { $errors[] = "Invalid Description!"; } if(!$price) { $errors[] = "Invalid Price!"; } if (count($errors) > 0) { foreach($errors AS $error) { echo ("<SCRIPT LANGUAGE='JavaScript'> window.alert('$error') window.location.href='admin-addservice.php' </SCRIPT>"); } } else { $sql = "INSERT INTO services(services , description , price) VALUES('$_POST[services]' , '$_POST[description]' , '$_POST[price]')"; $res = mysql_query($sql) or die (mysql_error()); ?> <script type="text/javascript"> function show_alert() { var msg = "Successfully Saved!"; alert(msg); } </script> <?php echo "<br/>"; echo '<script type="text/javascript"> show_alert(); </script>'; echo "<br/>"; echo "<br/>"; echo "<br/>"; } }
  22. Me too. What do you have in the add2.php file?
  23. You need to create that function before to use it.
  24. No, that's wrong!
  25. Where do you declare the protect function in that script?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.