lorsque l'utilisateur télécharger l'image ou le doc. L'image ou le document ne sont pas stockés dans le dossier de téléchargement, mais les champs restants sont correctement insérés dans la base de données. Je veux le stocker dans le dossier de téléchargement.Comment télécharger le fichier image dans php
Répondre
S'il vous plaît voir
if(isset($_REQUEST['submit'])){
$file=$_FILES['myfile']['name'];
$path="PATH YOUR DIRECTORY";
if(move_uploaded_file($_FILES['myfile']['tmp_name'],$path.$file))
{
echo "FILE UPLOAD SUCCESSFULLY";
}
else{
echo "FAILED";
}
}
En utilisant enctype dans votre <forme> attribut sinon votre fichier ne téléchargeant sur votre serveur.
enctype="multipart/form-data"
Code HTML
<form method="post" enctype="multipart/form-data">
File: <input type="file" name="myfile" />
<input type="submit" name="submit" value="Upload" />
</form>
plus d'informations, visitez
http://www.learnphp.in/mypage_6_File-uploading-with-PHP.html
merci pour la réponse chinamy sahu.iam en essayant votre code..image est télécharger avec succès son ok..mai un autre doute quand je inséré dans le code ci-dessus dans la forme comme
chinmay235 @ gmail. com envoyez-moi avec description ce que vous voulez. – Chinmay235
je vous remercie pour la réponse rapide chimamay j'avais envoyé mon code dans votre adresse e-mail chinmay vérifier. – user2615543
public function uploadImage()
{
//define a maxim size for the uploaded images in Kb
define ("MAX_SIZE","1000");
//checks if the form has been submitted
if(isset($_POST['picture']))
{
//reads the name of the file the user submitted for uploading
$image=$_FILES['file']['name'];
if ($_FILES["file"]["error"] > 0)
{
$this->errorMsg = $_FILES["file"]["error"] . "<br />";
$this->errors = 1;
}
//if it is not empty
//get the original name of the file from the clients machine
$filename = stripslashes($_FILES['file']['name']);
//get the extension of the file in a lower case format
$extension = $this->getExtension($filename);
$extension = strtolower($extension);
//if it is not a known extension, we
//will suppose it is an error and will not upload the file,
//otherwise we will do more tests
if (($extension != "jpg") && ($extension != "jpeg") &&
($extension != "png") && ($extension != "gif"))
{
//print error message
$this->errorMsg = "You must choose a jpeg, jpg,
png, or gif file";
$this->errors=1;
} else {
//get the size of the image in bytes
//$_FILES['image']['tmp_name'] is the temporary filename of the file
//in which the uploaded file was stored on the server
$size=filesize($_FILES['file']['tmp_name']);
//Store the extension for listing in session
$_SESSION["image_ext"] = $extension;
//compare the size with the maxim size
//we defined and print error if bigger
if ($size > MAX_SIZE*1024)
{
$this->errorMsg = "You have exceeded the size limit.";
$this->errors=1;
}
//we will give an unique name,
//for example the time in unix time format
$image_name= $item_num.'.'.$extension;
chdir("/home/public_html/");
try {
@mkdir($item_num, 0755);
chmod($item_num, 0755);
} catch (Exception $e) {
}
//we verify if the image has been uploaded, and print error instead
$imagePath = $_FILES['file']['tmp_name'];
//the new name will be containing the full
//path where will be stored (images folder)
$newname= $item_num."/".$image_name;
$copied = copy($imagePath, $newname);
//Now use that directory andmake the image
if (!$copied)
{
echo "Failure";
$this->errorMsg = "There was an error uploading your image.";
$this->errors=1;
}
}
//If no errors registred, print the success message
if(isset($_POST['picture']) && !$this->errors)
{
echo "success";
}
}
- 1. PHP: Télécharger le fichier
- 2. Redimensionner image télécharger php
- 3. PHP télécharger un fichier image par url
- 4. PlayFramework - Comment télécharger le fichier/image
- 5. php télécharger fichier image par code
- 6. Télécharger le fichier PHP
- 7. PHP télécharger le fichier
- 8. ExtJS & PHP Télécharger le fichier
- 9. Impossible de télécharger le fichier image en utilisant php
- 10. PHP Télécharger le fichier vers le serveur
- 11. PHP Télécharger en-têtes (Télécharger le fichier)
- 12. Télécharger une image dans un fichier avec php
- 13. comment télécharger le fichier en php
- 14. Télécharger le fichier php mail
- 15. Télécharger le fichier en PHP dans mysql
- 16. Formulaire PHP ne pas télécharger le fichier
- 17. comment télécharger le fichier compressd en php
- 18. Télécharger Image stockée dans le script php Amazon S3
- 19. Télécharger le fichier IMG rempli dans un fichier PHP?
- 20. Télécharger/télécharger Image problème android + PHP + Base64
- 21. PHP télécharger automatiquement le fichier
- 22. Windows Phone 7 - Télécharger le fichier (Image)
- 23. télécharger et montrer une image dans php
- 24. Comment télécharger le fichier sur Android avec PHP force télécharger
- 25. image PHP Télécharger Problème étrange
- 26. télécharger une image avec php
- 27. Comment télécharger une image avec PHP?
- 28. image télécharger sur le serveur
- 29. Comment télécharger un fichier/image via tastypie
- 30. Redimensionner le fichier image avant de le télécharger; Pourrions-nous écraser le fichier temporaire et télécharger?
au moins un peu de code – KyleK
Cette question est impossible de vous aider sans voir le code effectuant la télécharger. S'il vous plaît le modifier dans votre message. À une conjecture, vérifiez les autorisations de fichiers sur le dossier en cours de téléchargement. –
Plusieurs excellents didacticiels existent à ce sujet: http://www.w3schools.com/php/php_file_upload.asp – Vulcan