djjjozsi
thanks man i love you its working now
thax u soo much
phpbuilder is really great
thax
djjjozsi
thanks man i love you its working now
thax u soo much
phpbuilder is really great
thax
Hello,
Not at all
djjjozsi
can u help me in one more thing
i need a code that will get a upload from users in my website or got store in a particular folder
upload file is in any format like movie , .zip , image etc
or will display after upload in a particular page
You can see this step by step tutorial:
http://php.about.com/od/advancedphp/ss/php_file_upload.htm
After creating this, make a file list.
<?
/**
* Change the path to your folder.
*
* This must be the full path from the root of your
* web space. If you're not sure what it is, ask your host.
*
* Name this file index.php and place in the directory where the users upload.
*/
// Define the full path to your folder from root
$path = "full path to folder";
// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");
// Loop through the files
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "<a href=\"$file\">$file</a><br>>";
}
// Close
closedir($dir_handle);
?>
helo dijjjozsi
can i change the name of this file index.php
because index.php is already exist in my directory
hey and what about the display page???
A page which contain the file after upload
The code dijjjozsi posted lists the files in the path you specify; the "index.php" in the if() statement is simply there to exclude it from the listing.
hi,
lets see that tutorial, and in the 5. section(Putting It Together) you can see the results page.
You have to change this line to make a direct link to the uploaded file.
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo '';
But you must keep this script in your control,
so i recommend you to read the Final Thoughts part,
and the "security as possible" link.
Hello,
jjozsi
hi djjjozsi
hey when i an going throgh these steps of upload that provided by you
i got this error when i click on upload button
Notice: Undefined variable: uploaded_size in /www/oxyhost.com/m/y/h/myhotspot/htdocs/upload/upload.php on line 7
Notice: Undefined variable: uploaded_type in /www/oxyhost.com/m/y/h/myhotspot/htdocs/upload/upload.php on line 14
Warning: move_uploaded_file(upload/jumbo.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /www/oxyhost.com/m/y/h/myhotspot/htdocs/upload/upload.php on line 29
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpqJfHLR' to 'upload/jumbo.jpg' in /www/oxyhost.com/m/y/h/myhotspot/htdocs/upload/upload.php on line 29
Sorry, there was a problem uploading your file.:xbones::xbones::xbones:
?????:quiet:
Hello,
Yes, you're right, it has mistakes.
Here is the modificated version below, and if you want to see the modifications,
here is a video about it:
http://phptool.extra.hu/tutorials/troubleshooting_111/troubleshooting_111.php
<form enctype="multipart/form-data" action="uploader.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
<?php
if(!empty($_FILES))
{
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
$uploaded_size = $_FILES['uploaded']['size'];
$uploaded_type=$_FILES['uploaded']['type'];
//This is our size condition
if ($uploaded_size > 5000000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
}
?>
hey thax
its working fine now
djjjozsi
another problem
when i am going to open the index.php page which is in that directly where i upload all file it show an error
Unable to open /upload
what this??
u gave me the index.php code ........see prevoius post
hello,
in the file listing program:
if your upload folder located for example in wwwroot/my_site/program/ then you have to
set this folder from the root folder like this:
// Define the full path to your folder from root
$path = "wwwroot/my_site/program/upload";
Hello,
jjozsi.
again the same error
unable to open
i have pass the full path
Can you show us the "full path" that you tried?
yeah sure
// Define the full path to your folder from root
$path = "www.myhotspot.oxyhost.com/upload";
That's not a full local path, that's part of a URL.
A full path would look something like /home/myUsername/public_html/upload/ (just an example - it varies widely from server to server). Check out $_SERVER['DOCUMENT_ROOT'] to get the "full path" to the root of your website.
bradgrafelman
cant get you man
please write in detail what do i do???
Well you have two options:
<?php echo $_SERVER['DOCUMENT_ROOT'] ?>
This will show you the full local path on the server to the root of your website. You can then use this in your script we've been discussing in this thread.OR:
$path = $_SERVER['DOCUMENT_ROOT'] . '/path/to/dir'; // points to http://yoursite.com/path/to/dir
Obviously, option #2 is more portable/versatile, but you might make a script that echo's out the doc. root just for your own curiosity so you can actually see what I'm talking about by a full local path on the server itself (as opposed to a URL, such as http://mysite.com/path/to/dir).
it will only show
/www/ :quiet::quiet:
then
/www/upload
is the folder you need.