answersLogoWhite

0

How can we upload in php?

Updated: 9/22/2023
User Avatar

Wiki User

11y ago

Best Answer

this is file of index.php or any file that contains uploading area .......

....................................................................................

<body>

<form name="frmFile" method="post" action="fileuploadprocess.php" enctype="multipart/form-data">

<label>Select File</label>

<input type="file" name="flnFile" />

<br />

<input type="submit" value="Upload File" />

</form>

</body>

.....................................................................................................

fileuploadprocess.php that is in form action="fileuploadprocess.php"

<?php

//print_r($_FILES);

//echo(phpinfo());

$sType=$_FILES['flnFile']['type'];

echo($sType);

//echo("<br>");

$arrFileTypes=array("image/jpeg","image/png","image/gif");

$iFileSize=$_FILES['flnFile']['size'];

// For KBs

$iFileSize=$iFileSize/1024;

// For MBs

//$iFileSize=$iFileSize/1024;

echo($iFileSize);

echo("<br>");

//if($sType=="image/jpeg" $sType=="image/png" //$sType=="image/gif")

if($iFileSize<=100)

{

if(in_array($sType,$arrFileTypes))

{

$sDirectory="Uploadfiles/sajid";

if(is_dir($sDirectory))

{

}

else

{

mkdir($sDirectory,0777);

}

$dDateTime=date('mdyhis');

$sTempLocation=$_FILES['flnFile']['tmp_name'];

//$sDesignationLocation="Uploadfiles/".$dDateTime.$_FILES['flnFile']['name'];

$sDesignationLocation=$sDirectory."/".$dDateTime.$_FILES['flnFile']['name'];

//echo($sDesignationLocation);

move_uploaded_file($sTempLocation,$sDesignationLocation);

}

else

{

echo("File type error");

}

}

else

{

echo("File size Error");

}

?>

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can we upload in php?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you install PHP scripts?

You need to upload the scripts to web hosting space that support PHP.


Can you sen a code to upload photo in javascript or php?

Please go to www.google.com, and search for "php upload photo script" or something alike. I'm sure you'll find somthing there.


How do you upload an image to MySQL using PHP?

You cant upload an actual picture to MySQL, you can upload the URL but not the picture itself. You would have to upload this to your site first and then send the link to MySQL


How do you create a PHP script?

To create a PHP script all you have to do is create a new file, then save the file as "filename.php". It must have a .php file extension.After that open the file and put in the PHP tags like shown.Then you write your PHP script within those tags and upload to your web space and check it out.


How do you edit a PHP file?

Open it in Notepad. Add or remove whatever code you want. To test, you will have to upload it to a PHP enabled webhost, or you will need to install MySQL, PHP, and Apache on your computer. Use Editor to edit the PHP file. Example: Notepad++ , editplus ,Zend IDE ,Netbeans IDE


Why php not able to fetch the image from 'My Picture' in win XP to Script and diplay it?

PHP is a server-side language, and doesn't have access to your hard-drive. You have to get the user to upload the picture to the server, first.


How do you upload an image using PHP?

You upload the image in HTML using a form that includes the following field &lt;input type="file" name="fileUpload" /&gt; After the form is submitted, you can access it with the $_POST variable as $_POST['fileUpload'] http://www.tutorialsscripts.com/free-php-scripts/file-and-directory-script/image-upload.php


How do you find version of PHP in uniform server?

The easiest way is to create a file with a name ending in .php (such as info.php), containing only these 3 lines: &lt;? phpinfo(); ?&gt; Upload this file to your web space and access it using your browser. It will show a lot of information about your webserver and the php version running on it.


How do you install a PHP program into a website that is hosted at bluehost.com?

Well assuming they allow PHP, all you would have to do is upload the file to your web space and then visit the page in your web browser. Apart from that there's not much else too it.


Imageuploading in PHP using OOP?

It is possible to have an image upload object. You will simply create a class that takes the parameters required for an upload and pass it the upload resource given by the relevant $_FILES[''] superglobal. For instance one could use code like the following when calling this class: // Give the constructer the directory $uploader = new Upload("../galleryimages"); into which to upload. // The rest of the params. $notice = $uploader-&gt;uploadimage($_FILES['fileupload'], UPLOAD_TYPE_IMAGES, 220, 188, UPLOAD_KEEP_ASPECT);


Are there any tags in HTML to upload or download a file?

You will need to use a script such as PHP or ASP for uploading purposes. You can use an anchor tag for downloading:right click and choose 'save as' to download


What is 10 percent in Php 250?

Answer: Php 2510% of Php 250= 10% * Php 250= 0.10 * Php 250= Php 25