it has always been my practice that when ever i use images i name them like
walls_ico , bu_hover
so when i give paths they go like
<img src="images/walls_ico.ico" />
<img src="buttons/bu_hover.png" />
UNTIL now when i am on a project where users upload files...
i was wondering is it okay to have spaces between file and folders name like
<img src="buttons/bu hover.png" />
The src attribute should contain a valid URL. Since space characters are not allowed in URLs, you have to encode them.
You can write:
<img src="buttons/bu%20hover.png" />
But not:
<img src="buttons/bu+hover.png" />
Because, as DavidRR rightfully points out in his comment, encoding space characters as + is only valid in the query string portion of an URL, not in the path itself.
Quoting HTML5 to back Frederic that spaces are not allowed:
http://www.w3.org/TR/html5/links.html#attr-hyperlink-href:
The href attribute on a and area elements must have a value that is a valid URL potentially surrounded by spaces.
The definition of "valid URL" points to: http://url.spec.whatwg.org which defines URL code points https://url.spec.whatwg.org/#url-code-points:
The URL code points are ASCII alphanumeric, "!", "$", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "=", "?", "#", "_", "~", and code points in the ranges U+00A0 to U+D7FF, U+E000 to U+FDCF, U+FDF0 to U+FFFD, U+10000 to U+1FFFD, U+20000 to U+2FFFD, U+30000 to U+3FFFD, U+40000 to U+4FFFD, U+50000 to U+5FFFD, U+60000 to U+6FFFD, U+70000 to U+7FFFD, U+80000 to U+8FFFD, U+90000 to U+9FFFD, U+A0000 to U+AFFFD, U+B0000 to U+BFFFD, U+C0000 to U+CFFFD, U+D0000 to U+DFFFD, U+E1000 to U+EFFFD, U+F0000 to U+FFFFD, U+100000 to U+10FFFD.
The spec then uses the term URL code points on various parts of the parsing algorithm as:
If c is not the EOF code point, not a URL code point, and not "%", parse error.
for the scheme, authority, relative path, query state and fragment states: so the entire URL.
If you are using PHP
then find out this code
$result = mysqli_query($con,$sql);
//echo $ip."<br />";REGEXP
//echo $name."<br />";
echo "<table border=2px style='border-radius=20px;' align=center><tr>
<th>Document ID</th>
<th>Document Name Type</th>
<th>Download Documents</th>
</tr>";//<th>Project Document Type</th>
while($row = mysqli_fetch_array($result)) {
$path1=$row['FOLDERNAME'] .'/'. $row['FILENAME'] .'.'. $row['DOCTYPE'];
$path=str_replace(" ", '%20', $path1);
echo "<tr>";
echo "<td>" . $row['DocID'] . "</td>";
// echo "<td>" . $row['PROJDOCTYPE'] . "</td>";Thank you. Your Apple ID is now ready for use.
echo "<td>" . $row['DOCNAME'] . "</td>";
echo '<td><a href=Tender/'.$path.'>'.$row['DOCNAME'].'</a></td>';
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
<body>
<img src="file:///C|/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Water lilies.jpg"
</body>
spaces will be allowed only when you are working in local hosts
Related
I am trying to remove an image from a header.phtml file. It has been hard coded into the header.phtml in addition to the regular magento header image. I cannot access the image I want to delete through magento. I have found the line of code where it has been added to the header.phtml but don't know what the next step is to change this... can I delete the header.phtml file from our sftp and then re-upload it with the appropriate line of code deleted or will that ruin the whole site?
Your help is very much appreciated! I am a novice. HTML good.. everything else clueless but definitely know the line of code that has to go.
Thank you!
Maybe you add the echo function " ";
For example
<table border = "3">
<tr>
<td>
<? php
$ files = glob ("img / *");
foreach ($ files as $ file) {
echo "<div class = 'divimages'>";
echo '<img src = "'. $ file. '" />';
echo "<input type = 'submit' value = 'Delete image' /> <br>";
echo "</ div>";
}
?>
</ td>
</ tr>
</ table>
I have a website for school where every teacher is going to have a page. Each teacher's page will have a spot for them to upload a PDF. I want this to then show in a viewer on the page so students see the Viewer when they access it.
How would I code into the website allowing the user to upload a PDF and not have it replaced until somebody else uploads a PDF?
so far I have the code to upload a document.
<form method="POST" enctype="multipart/form-data" action="fup.cgi">
File to upload: <input type="file" name="upfile"><br/>
Notes about the file: <input type="text" name="note"><br/>
<br/>
<input type="submit" value="Press"> to upload the file!
</form>
How can I get it to go into a viewer below? and that it saves until replaced.
1 - First thing you are not able to upload file to server but your form action is claiming to use CGI,
2 - Second i cant really get what you want but the following code can upload files to server its in PHP and otherthing are you using SQL or what Database are you using it seems you also need database
<?php
set_time_limit(0);
if(!is_dir("uploads")){
$uploadDir = mkdir("uploads");
}
$allowedExts = array("pdf", "docx", "doc");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "application/pdf")
|| ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|| ($_FILES["file"]["type"] == "application/msword"))
&& ($_FILES["file"]["size"] < 200000000000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("/uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/uploads/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
Do you want to display pdf thumb, icon, or read the pdf
I am using this code to store HTML code in a variable called $conversions
$conversions = "GBP " . number_format($file*0.84) . "CHF " . number_format($file*1.23)
However I can't seem to figure out how to add a <br> before the word "CHF ".
Any ideas?
The whole code is as follows:
<?php
$file = get_field('fl_price');
if(trim($file) == ""){echo 'Price on Application' ;}else{$conversions = "GBP " . number_format($file*0.84) . "<br />CHF " . number_format($file*1.23) ;echo 'EUR ' . number_format($file) . "</br><a class=\"wp-tooltip\" title=\" $conversions \">Other Currencies</a>" ;}
?>
$conversions = "GBP " . number_format($file*0.84) . "
CHF " . number_format($file*1.23);
Echoing $conversions will now have a HTML-linebreak before CHF.
You are adding your string to an attribute of <a> called title. This isn't going to be displayed and is certainly not going to render any HTML (like a br tag).
edit:
As per OptimusCrime's suggestion, this does work:
http://jsfiddle.net/5rM4u/1/
Replace your <br/> with
and you're good to go.
You are trying to print the $conversions variable in the "title" of the "a" tag. just using <br /> will not work.
See some of the answers to this question "How can I use a carriage return in a HTML tooltip?" it may contain the answer that you are looking for.
I know how to use the smarty mailto function to create mailto anchor links with encoding. But I am wondering if it is possible for example to insert html image tags [<img>] into the output of this function.
I have tried:
[SMARTY]
{$text = '<img src="/images/qr_code.jpg" alt="member sign up qr code">'}
{mailto address="test#example.com" encode="hex" text={$text}}
[HTML RESULT]
<a href="mailto:%74%65%73%74#%65%78%61%6d%70%6c%65.%63%6f%6d">
<img src="/images/qr_code.jpg"
alt="member sign up qr code" >
</a>
I am after this output rather:
<a href="mailto:%74%65%73%74#%65%78%61%6d%70%6c%65.%63%6f%6d">
<img src="/images/qr_code.jpg"
alt="member sign up qr code">
</a>
It seems, from reading this code https://bitbucket.org/pferor/dbless/src/04b228943e39/dbless/lib/smarty/plugins/function.mailto.php, that when you use the "hex" encoding it not only encodes the address but also the text (line 147):
$text_encode = '';
for ($x=0; $x < strlen($text); $x++) {
$text_encode .= '&#x' . bin2hex($text[$x]).';';
}
Not sure if that's the problem though.
If you don't mind editing the Smarty source youmight be able to change this line (153):
return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
To this:
return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text.'</a>';
To make it work.
If you try "none" encoding does it show the image then?
I have a minor problem, i just want a simple image preview with a go back button or something similar, I made
<div id="image1">
<a href="../assets/image_large1.jpg"><img src="../assets/image_1.jpg" width="160" height="107" alt="Example 1" />
</div>
but I don't know how to put a button inside
how could I do it?
In the most simple solution to your problem, I would do special show_image.php page, for example:
<?php
$directory = 'assets/';
$filename = $_GET['image'];
if(empty($filename) || is_file( $directory . $filename ))
{
echo 'No such image!';
}
else
{
echo '<img src="' . $directory . $filename . '" />';
}
echo '<br />';
echo 'Go back';
exit;
And link for the image will be: http://mysite.com/show_image.php?image=image_1.jpg
Of course this code should be made more secure and this thing could be done other ways.