Html - how to make the browsing button open in a desired path - php

I have this html code(+some backdoor php codes) to delete images from my website, but the problem is that I need that browsing dialoge to be opened in a specific path and be stuck on that path, I like I don't want the user to be able to navigate through the folders as he likes, is that possible to be done in any ways?
<table>
<tr>
<td>Select a project : </td>
<td><input type='file' name='userFile'><br></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="upload_btn" value="delete"></td>
</tr>
</table>
thanks

No, it isn't … and it shows the user's local file system rather then the servers anyway.
Write some server side code to generate a list of files that could be deleted and generate an HTML document listing them instead.

Related

my php file doesnt output but instead shows source file

I am trying to add a php code in my html file, but whenever i do, my file instead of outputting my expected outcome, it instead presents the source code
again, i am creating a server for my project at school and i am a total noob in programming as i learn it all by myself without formal education about it. i tried to save the file as both .html and .php, although .html presents the output, but not the desired one. now i have two files below and since i am a noob in programming, my concept was to have users input the form in the .html file and output in on an identical one but in .php
this is the first file, saved in ABM11.html
<form action="AMB11.php" method="post"><table border="0">
<tr>
<td>Name</td>
<td align="center"><input type="text" name="StudentName" size="30"></td>
</tr>
<tr>
<td>Subject</td>
<td align="center"><input type="text" name="Subject" size="30"></td>
</tr>
<tr>
<td>Final Grade</td>
<td align="center"><input type="text" name="FinalGrade" size="30"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="submit"></td>
</tr>
</table>
</form>
this is the second file, saved as ABM11.php
<?php
$studentname = $_POST['StudentName'];
$subject = $_POST['Subject'];
$finalgrade = $_POST['FinalGrade'];
echo $studentname '<\br>';
echo $subject '<\br>';
echo $finalgrade '<\br>';
?>
basically i just want users to answer a form then have that data be posted on the same page perpetually, not have my noob source code presented
it seems , the problem with your web server , weather you are using apache or nginx . its not running properly or its not configured properly on your local machine so rather then executing php code its just showing that file on the browser .
You can debug like , create one simple php file just like echo "yourname "; and put it to your www directory and try to run it form browser if the server is proper configured then it must print and if its not prited then its mistake with your local server configuration .
and also on your source code there is one mistake of echo and .
Wrong : echo $finalgrade '<\br>';
True : echo $finalgrade .'<\br>';
You must concat br with .
that is mistake 110% but as you said in your question the code is showing on the page is not only because of this , its surely configuration problem
if . is the only mistake then it wont show you the source code on the page but you will get any php error if thats the only issue .so check your config well first.
Thanks
Akshay Champavat
If you combine variables and strings in an echo, you need to add dots to connect them. So instead of this
echo $studentname '<br>';
you need to write it as
echo $studentname.'<br>';
And similar in all other lines.
(and no backslashes, by the way!)
And also ("sourcecode displayed...") make sure to open/call the php file via a server (for example XAMPP, via localhost), not simply as a file on your computer.

i am trying make an online music library, where admin will able to upload music files

i am storing the path of the .mp3 file in the database, but when uploading a file, the actual file is not uploading, just the name and the user info. here is the coding
<?php
if($_POST[ins])
{
#mkdir("songs");
$spath="songs/".time()."-".$_FILES[sonsor][name];
copy($_FILES[sonsor][tmp_name],$spath);
$son="insert into `songs` values('','$_POST[sonam]','$_POST[soalmoi]','$spath')";
//echo $s;
mysql_query($son);
header("location:songs.php?");//action=show&msg=va
}
?>
<form method="POST" action="" enctype="multipart/form-data">
<table>
<tr>
<td>Song Name</td>
<td><input type="text" name="sonam"></td>
</tr>
<tr>
<td>Album/Movie</td>
<td><input type="text" name="soalmoi"></td>
</tr>
<tr>
<td>Song File</td>
<td><input type="file" name="sonsor"></td>
</tr>
<tr>
<td><input type="submit" name="ins"></td>
</tr>
</table>
</form>
the file path is updating but the actual .mp3 file is not coping in the songs folder
When you submit a file via POST to PHP, you must use $_FILES to get the file, instead of $_POST.
In your case, to access the file and its properties, you should use:
$fi = $_FILES["sonsor"]
Which is an associated array representing the file uploaded in the field with the name sonsor.
Now, to complete the upload, you most likely will want to move the temporary file to a particular directory and rename it according to what is in the database. PHP recommends move_uploaded_file():
move_uploaded_file($fi["tmp_name"], $target_path)
The method returns true if it worked properly. It is recommended to put more safety checks into place; check out W3Schools for an example.

Comment form/submission trouble?

Please note: the site I'm working with doesn't allow the use of Javascript. It's a huge pain, but I can't do anything about it. I'm looking for (hopefully) a work around for my problem.
This is a bit of a weird situation, so I'm going to try and explain my problem as best as possible without getting too complicated.
I write style sheets and stuff for this site I go on called AniRoleplay, which is basically an cheap knock-off version of the old Myspace. I was making a custom bulletin, trying to move the comment section to another location on the page. To do that, I copy/pasted the form that the site uses by default to post comments.
That code is as follows:
<table align='center' class='txt_label'>
<tr>
<td width='100%'><p align='left'> <font face='Verdana' color='#000000' size='2'> <b>Add a Comment :</b> </font> </td>
</tr>
<tr>
<td width='100%'><p align='left'>
<textarea id='textarea1' name='comment_text' rows='5' cols='30' style='width:700; height:75'></textarea>
<br>
<br>
<b><font color='black'>Your image will display properly if this URL ends in .GIF, .PNG or .JPG. Anything else will not work.</font></b><br>
<input name='image' type='text' size='95' style='width:700px' placeholder='Image URL --- EXAMPLE: http://i.imgur.com/s7BBFmm.JPG'/>
</td>
</tr>
<tr> </tr>
<tr>
<td width='100%'><p align='left'>
<INPUT class=flat id=Submit onclick=document.theForm.details.value=idContent.document.body.innerHTML; type=submit value='Add Comment' name=Submit>
</td>
</tr>
</table>
However, when I added it and tested it.. I got this error from the site:
"You did not enter any text for your comment."
The result I'm looking for is something like this:
http://i.stack.imgur.com/1XaOg.jpg
I got that result by accident, but had no idea how I had gotten it. I ended up going back to an older version of the layout though because the submit button wasn't responding, but even when I did get it to respond, I kept constantly running into the "no text" error.
Last but not least, here's the link to the CodePen I have been working on for this layout: http://codepen.io/Peechiee/pen/qOBQZe?editors=110
I have seriously run out of ideas here. D: I don't know anything about PHP (I'm self taught and am pretty much only familiar with CSS and HTML) so I don't know if that is relevant to the situation but I'd really really appreciate some help.
Thanks in advance!

Implementing PHP Inside a HTML Table

Currently, I am building a table full of content. I can sucessfuly make one row that has one cell (the first cell) saying data, however when I attempt to use php to echo something, it does not show up. Why is this?
If you need my whole program I would be happy to include it, however to stay clean I am going to only include a section of the table.
Code:
<tr>
<td>data </td>
<td><?php echo "hi"; ?> </td>
<td> </td>
<td> </td>
</tr>
What you are doing is very right.
There are two reasons why that may not be working.
1- check if your filename ends with .php
and
2- check if you are running your code from a webserver that supports php.
To know if php is installed just try to right a simple php page iwth the following content.
if it renders it means you have php installed

showing one tr and hiding the other in same if both have the same class

I have a page to get source code from remote site through File Get Contents PHP function. It works well, and gets the code and echoes it perfectly.
The problem is that there are 2 <tr> having the class <tr class="sectiontableentry2">.
When I try to hide one of them using CSS display: none;, then both disappear.
I want to hide one of them only.
N.B: I don't have access to the code itself as I get it from the remote site.
Here is the code that I get:
<tbody>
<tr class="sectiontableentry2">
<td width="18"><img title="Flash" src="../images/soft_icons/flash.png" alt="Flash" /></td>
<td width="80"><a>Flash:</a></td>
<td>Link#1 ( Stable, Recommended Stream! ) <img style="vertical-align:text-bottom;" src="http://www.streamhunter.eu/images/info-icon.png" border="0" alt="Important Notice!" title="Important Notice!" /></td>
</tr>
</tbody>
<tr class="sectiontableentry2">
<td width="18"><img title="Iframe" src="../images/soft_icons/flash.png" alt="Flash" /></td>
<td width="80"><a>Flash:</a></td>
<td><a href='javascript:openWindow("index1.php?option=com_lsh&view=lsh&event_id=148636&tv_id=929&tid=32666&channel=0&tmpl=component&layout=popup&Itemid=335","730","730")' >Link#1</a> (640x360) </td>
</tr>
</tbody>`enter code here`
As you can see there are two <tr> both having same class. How can hide the 1st one and let the 2nd to show normally?
This is difficult, because there must be a whole lot more HTML not includeded, however if there are only ever two instances of the .sectiontableentry2 class, the below JQuery code will find the first and hide it.
//this will select the first tr with the class .sectiontableentry2
$(".sectiontableentry2").first().hide();

Categories