FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Upload file





landxxx
How easy upload file with PHP. But I have more problems with autentification this file on server beacuse I'd this file for preview on page

thank you
Simulator
Can you post your code, and have you set your folder to 777
landxxx
Simulator wrote:
Can you post your code, and have you set your folder to 777


I know it's 777 premission who is problem

I have any script for my news portal, for upload picturs on news

Question Question Question Question Question Question
afracsass
hard to grab what you are asking for.
???????????

Please be more specifiec.

good luck,

landxxx wrote:
Simulator wrote:
Can you post your code, and have you set your folder to 777


I know it's 777 premission who is problem

I have any script for my news portal, for upload picturs on news

Question Question Question Question Question Question
landxxx
afracsass wrote:
hard to grab what you are asking for.
???????????

Please be more specifiec.

good luck,

landxxx wrote:
Simulator wrote:
Can you post your code, and have you set your folder to 777


I know it's 777 premission who is problem

I have any script for my news portal, for upload picturs on news

Question Question Question Question Question Question


Do you me send any source cod for upload script.

I have many com but this code have more error

thank you
afracsass
example code for uploading file...

html code

Code:
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>


php code

Code:
<?php

// Where the file is going to be placed
$target_path = "./";
$ufilename = $_FILES['uploadedfile']['name'];

/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$uploadfile = $target_path.$ufilename;

if($ufilename != ""){
print "<pre>";
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadfile)) {
   print "File upload succeeded!";
   print "Uploaded file information:\n";
   print_r($_FILES);
} else {
   print "Upload failed!:\n";
   print_r($_FILES);
}
print "</pre>";
}


?>


try it and good luck~
landxxx
afracsass wrote:
example code for uploading file...

html code

Code:
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>


php code

Code:
<?php

// Where the file is going to be placed
$target_path = "./";
$ufilename = $_FILES['uploadedfile']['name'];

/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$uploadfile = $target_path.$ufilename;

if($ufilename != ""){
print "<pre>";
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadfile)) {
   print "File upload succeeded!";
   print "Uploaded file information:\n";
   print_r($_FILES);
} else {
   print "Upload failed!:\n";
   print_r($_FILES);
}
print "</pre>";
}


?>


try it and good luck~



but this source cod on my server is inccorect.

I think about send picture via mail

Which is cod for mail with attachment (*.jpg and *.gif)

And do you me post this cod

please


thak you
openaasman
there could be one reason if ur code is right that you wouldn't be having write permission on that folder
give me ur code i will correct it


mathiaus wrote:
Please do not double post
MM357
Yes My code aslo did not work.

My Code was :
Code:


// File Name Issues
$name=$_FILES['filef']['name'];
$destination = $_SERVER['DOCUMENT_ROOT']."/files/".$_FILES['filef']['name'];
$temp_file = $_FILES['filef']['tmp_name'];

// Moving Final File
move_uploaded_file($temp_file,$destination);


When I had a Direct admin host, The Upload resulted on an error saying :-

Quote:

Warning: move_uploaded_file(/home/mm357/domains/imwcreations.be/public_html/power2009/files/bigsig.jpg): failed to open stream: No such file or directory in /home/mm357/domains/imwcreations.be/public_html/files.php on line 62

Warning: move_uploaded_file(): Unable to move '/tmp/phphgWv76' to '/home/mm357/domains/imwcreations.be/public_html/power2009/files/bigsig.jpg' in /home/mm357/domains/imwcreations.be/public_html/files.php on line 62
avk
Hello
Here is the script

Code:

Browse a File to Upload: <i>file must be 1MB or less. (1048576 bytes)</i><br>
<input type="file" name="filetoupload"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">
<br>
<input type="Submit" value="Upload File">
</form>

<?php
/*  Description -----------------------------------------------------
The Super Global Variable $_FILES is used in PHP 4.x.x.
$_FILES['upload']['size'] ==> Get the Size of the File in Bytes.
$_FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File.
$_FILES['upload']['name'] ==> Returns the Actual Name of the File.
$_FILES['upload']['type'] ==> Returns the Type of the File.

So if I filetoupload the file 'test.doc', the $_FILES['upload']['name']
would be 'phptut.doc' and $_FILES['upload']['type'] would be 'application/msword'.
---------------------------------------------------------------------*/
// this is the upload dir where files will go.
//Don't remove the /
//Chmod it (777)
$upload_dir = "../";   //change to whatever you want.
// files less than 1MB
$size_bytes = 1048576; //bytes  will be uploaded
//check if the directory exist or not.
if (!is_dir("$upload_dir")) {
   die ("The directory <b>($upload_dir)</b> doesn't exist");
}
//check if the directory is writable.
if (!is_writeable("$upload_dir")){
        die ("The directory <b>($upload_dir)</b> is NOT writable, Please Chmod (777)");
}

//Check first if a file has been selected
//is_filetoupload_file('filename') returns true if
//a file was filetoupload via HTTP POST. Returns false otherwise.
if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
{

//Get the Size of the File
$size = $_FILES['filetoupload']['size'];
//Make sure that $size is less than 1MB (1000000 bytes)
if ($size > $size_bytes)
{
echo "File Too Large. Please try again.";
exit();

}
// $filename will hold the value of the file name submetted from the form.
$filename =  $_FILES['filetoupload']['name'];
// Check if file is Already EXISTS.
if(file_exists($upload_dir.$filename)){
   echo "Oops! The file named <b>$filename </b>already exists";
   exit();
}

//Move the File to the Directory of your choice
//move_filetoupload_file('filename','destination') Moves an filetoupload file to a new location.
if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$upload_dir.$filename)) {

//tell the user that the file has been filetoupload
echo "File (<a href=$upload_dir$filename>$filename</a>) uploaded!";


}
else
{
//Print error
echo "There was a problem moving your file";
exit();

}
}

?>
cybernytrix
Uploading multiple files is not an easy thing... it is so clumsy. Any one has a better idea?
I tried the ftp thing but it is even worse Sad
AOP Web Development
If you wish to upload multiple files just set the upload into arrays
lukand
Code:

Browse a File to Upload: <i>file must be 1MB or less. (1048576 bytes)</i><br>
<input type="file" name="filetoupload"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">
<br>
<input type="Submit" value="Upload File">
</form>

<?php
/* Description -----------------------------------------------------
The Super Global Variable $_FILES is used in PHP 4.x.x.
$_FILES['upload']['size'] ==> Get the Size of the File in Bytes.
$_FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File.
$_FILES['upload']['name'] ==> Returns the Actual Name of the File.
$_FILES['upload']['type'] ==> Returns the Type of the File.

So if I filetoupload the file 'test.doc', the $_FILES['upload']['name']
would be 'phptut.doc' and $_FILES['upload']['type'] would be 'application/msword'.
---------------------------------------------------------------------*/
// this is the upload dir where files will go.
//Don't remove the /
//Chmod it (777)
$upload_dir = "../"; //change to whatever you want.
// files less than 1MB
$size_bytes = 1048576; //bytes will be uploaded
//check if the directory exist or not.
if (!is_dir("$upload_dir")) {
die ("The directory <b>($upload_dir)</b> doesn't exist");
}
//check if the directory is writable.
if (!is_writeable("$upload_dir")){
die ("The directory <b>($upload_dir)</b> is NOT writable, Please Chmod (777)");
}

//Check first if a file has been selected
//is_filetoupload_file('filename') returns true if
//a file was filetoupload via HTTP POST. Returns false otherwise.
if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
{

//Get the Size of the File
$size = $_FILES['filetoupload']['size'];
//Make sure that $size is less than 1MB (1000000 bytes)
if ($size > $size_bytes)
{
echo "File Too Large. Please try again.";
exit();

}
// $filename will hold the value of the file name submetted from the form.
$filename = $_FILES['filetoupload']['name'];
// Check if file is Already EXISTS.
if(file_exists($upload_dir.$filename)){
echo "Oops! The file named <b>$filename </b>already exists";
exit();
}

//Move the File to the Directory of your choice
//move_filetoupload_file('filename','destination') Moves an filetoupload file to a new location.
if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$upload_dir.$filename)) {

//tell the user that the file has been filetoupload
echo "File (<a href=$upload_dir$filename>$filename</a>) uploaded!";


}
else
{
//Print error
echo "There was a problem moving your file";
exit();

}
}

?>



this code on my computer don't compile, but one simple code from internet is good for me and this code I use
Related topics
loadurl
Upload Script
Following error popped up when trying to upload an avatar
Upload Siteleri ve Tanýtýmlarý...
[RESOLVED] php file upload problem
File upload class problem.
Upload file porblem {fixed}
Upload File button at the top
upload form
upload File using ajax php or IFrame
Nothings Working ? Permissions -- Account Creator
Can't upload avatars
upload file to server using html form and CGI C
Your connection has timed out error during uploading file
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.